Guest User

Different C for loop

a guest
Jan 9th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #define LIMIT 100
  3.  
  4. void main()
  5. {
  6.     char s[LIMIT];
  7.     bool terminate=false;
  8.     const char termChars[] = {EOF, '\n', '\r', '\e', 0};
  9.  
  10.     for(int i=0; i<LIMIT && terminate==false; i++)
  11.     {
  12.         c=getchar();
  13.  
  14.         for(int j=0; termChars[j]!=0 && c!=0; j++)
  15.         {
  16.             if(c==termChars[j])
  17.             {
  18.                 c = 0;
  19.                 terminate = true;
  20.             }
  21.         }
  22.  
  23.         s[i]=c;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment