Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



Embedded Systems Building Blocks: Complete and Ready-To-Use Modules in C    (ISBN: 0879306041)


 

 List Price: $89.95
 Our Price: $62.97
 Used Price: $39.00

 Release Date: February, 2000
 Manufacturer: CMP Books (Hardcover)
 Sales Rank: 14,998

 Author: Jean J. Labrosse









More Info

 For Loop 2002-01-05 19:07:03
 
Category: source:c:general
Description: Example of a for(;;) loop
Platform: unix/win
Author: mind
Viewed: 1983
Rating: 3/5 (1 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
for.c
/* for.c by mindsport [mind@infract.net]
 *
 * example on a for() loop
 *
 * 01/05/02
 *
 */


#include <stdio.h>

int main() {
  int count; /* declare count as an integer */
  int max = 10; /* declare max as an integer of 10 */
  char msg[]="Hello!\n"; /* define msg as a string with text Hello! */

  for(count = 0; count < max; count++) /* loop until count reaches 10 */
    fprintf(stderr, "%i: %s", count, msg); /* foreach incriment print 'msg' 10 times */

  /* note ++ is used to increase an integers size, -- is used to decrease an
   * integers size.. for a more realistic count change 0 to 1 */

  /* you could also use for(;;) as an endless loop */

  /* as you may have noticed I didn't add a opening { or closing } bracket
   * in my for() statement, Because I only have one expression following it
   * but if you have more than one expression following your for() statement
   * add an opening and closing bracket to your for() statement:
   *
   * for(count = 0; count < max; count++) {
   *   fprintf(stderr, "%i: %s", count, msg);
   *   fprintf(stderr, "Line number: %i\n", count);
   * }
   *
   */
}
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?