home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16655 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  1.4 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!Informatik.Uni-Dortmund.DE!fbi-news!grossjoh
  2. From: grossjoh@petty.ls6.informatik.uni-dortmund.de (Kai Grossjohann)
  3. Newsgroups: comp.lang.c++
  4. Subject: basic question
  5. Date: 20 Nov 92 19:22:07
  6. Organization: Universitaet Dortmund, Lehrstuhl Informatik VI
  7. Lines: 38
  8. Distribution: world
  9. Message-ID: <GROSSJOH.92Nov20192207@petty.ls6.informatik.uni-dortmund.de>
  10. Reply-To: Kai Grossjohann <grossjoh@ls6.informatik.uni-dortmund.de>
  11. NNTP-Posting-Host: petty
  12.  
  13. Hi all, 
  14.  
  15.  
  16. this has GOT to be a FAQ, but I ask anyway: Suppose I have:
  17.  
  18.     int i;
  19.     for ( i=0; i<10; i++ ) {
  20.         cout << "Hey, you!" << endl;
  21.     }
  22.  
  23. After the loop, can I _rely_ on the fact that i==10? I mean, what does the
  24. language specification say? I really don't want to do anything that's not
  25. allowed here, but I hesitate to write
  26.  
  27.     int i; int j;
  28.     j = 0;
  29.     for ( i=0; i<10; i++ ) {
  30.         cout << "Hey, you!" << endl;
  31.         j++;
  32.     }
  33.  
  34. and then use the fact, that after the loop, j==10.
  35.  
  36. What do you think?
  37.  
  38. Thanx for your help?
  39.  
  40.     -- Kai
  41. --
  42. --
  43.   Kai Grossjohann            Phone (voice): 49 231 75 30 15
  44.   Baroper Str. 331 App. 510  E-Mail: 
  45.   W-4600 Dortmund 50         grossjoh@ls6.informatik.uni-dortmund.de
  46.   Germany                    
  47. --
  48. There are two ways to solve this problem: the hard way, and the
  49. easy way. Let's start with the hard way.
  50.                         -- W. Schneider, from a Physics lecture
  51.