SabirSazzad

Stop input of char (Detail)

Feb 20th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. main ()
  3. {
  4.  
  5.     char name [100], ch;
  6.     int i=0;
  7.     while (i<100)
  8.     {
  9.         if((ch=getchar())!='\n')
  10.         {
  11.             name[i++] = ch;
  12.         }
  13.         else
  14.         {
  15.             break;
  16.         }
  17.         name [i] = '\0';
  18.  
  19.  
  20.     }
  21.     printf("%s",name);
  22.     return 0;
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment