Advertisement
Broatlas

Untitled

Feb 19th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. /********************************************************/
  3. #define MAX 200
  4. /********************************************************/
  5. int readCommands( char c [ ] );
  6. /********************************************************/
  7. int main( void ) {
  8.     char commands[ MAX ] = { 0 };
  9.     int ncmds;
  10.     int count; 
  11.     ncmds = readCommands( commands );
  12.    
  13.     for(count = 0;count<ncmds;count++){
  14.         fprintf(stdout,"%1s\n",&commands[count]);
  15.     }
  16.     printf("ncmds:%d\n",ncmds);
  17.     return 0;
  18.     }
  19. /***********************************************************/
  20. int readCommands( char commands[] ) {
  21.  
  22.     int ncmds = 0;
  23.     int count = 0;
  24.     char val;
  25.     while(fscanf(stdin, "%1s\n",& val) != EOF){
  26.         fprintf(stdout, "\n Letter: %1s", &val);
  27.         commands[ncmds] = val;
  28.         ncmds = ncmds + 1;
  29.     }  
  30.     return ncmds;
  31.     }
  32.  
  33. /*************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement