Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,671 of 33,346    |
|    Ulrich Eckhardt to All    |
|    Re: How to write output with an indent    |
|    14 Nov 11 09:45:15    |
      e3a009fa       From: ulrich.eckhardt@dominolaser.com              Am 13.11.2011 18:06, schrieb Jayden Shui:       > I'd like to have an itemized output like       >       > 1. Topic       > 1.1 Sub Topic       > 1.2 Sub Topic       > 1.2.1 Sub Sub Topic       > 1.2.2 Sub Sub Topic       > 1.3 Sub Topic       > 2. Topic       >       > and so on.       >       > The indent is increased when a sub is introduced. My question is that       > how can I use stream to handle such-like output?              You can write spaces at the beginning of a line in order to indent the       input, but I guess that's not your question. Since I guess this is       homework, I'm also not sure where to stop giving away hints in order not       to spoil your exercise.              Anyhow, the idea is that the beginning of each sub adds one level of       indentation and the end removes it again. If you can, bind this to the       scope of an object, that way you can't forget the removing call.              You can store the current level in a simple variable, which must be       available to the code doing all the writing inside. There are several       ways to store this:       1. use a global indent counter       2. pass the indent counter by reference to all writing functions       3. store the indent counter inside the stream using xalloc/iword                     Note that if you need further help, you should try to demonstrate some       own effort first, i.e. some specific code. This is because people here       generally don't do other people's homework.              Good luck!              Uli                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca