Advertisement
xeritt

Ввод строки fgets/scanf. Откуда лишний символ?

Nov 16th, 2016
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define LEN 128
  4. int main(int argc, char **argv)
  5. {
  6.     char mas[LEN];
  7.     fgets(mas, LEN, stdin);
  8.     int count = strlen(mas);
  9.     for (int i = 0; i < count; i++){
  10.         printf("%d:[%c]",i , mas[i]);
  11.     }
  12.     mas[count-2] = '!';
  13.     mas[0] = '?';
  14.     printf("\n");
  15.     printf(mas);
  16.    
  17.     scanf("%s", mas);
  18.     count = strlen(mas);
  19.  
  20.     for (int i = 0; i < count; i++){
  21.         printf("%d:[%c]",i , mas[i]);
  22.     }
  23.     mas[count-1] = '!';
  24.     mas[0] = '?';
  25.     printf(mas);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement