Advertisement
silentkiler029

tahmid-string-01

Jun 16th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     char str1[15];
  7.     printf("enter your first name: ");
  8.     //scan your name (less than 10 character)
  9.     scanf("%s", str1);
  10.  
  11.     printf("when the value was scanned:\n");
  12.     printf("%s\n\n", str1);
  13.  
  14.     //suppose the previous input was "tahmid"
  15.  
  16.     char name[15];
  17.     name[0] = 't';
  18.     name[1] = 'a';
  19.     name[2] = 'h';
  20.     name[3] = 'm';
  21.     name[4] = 'i';
  22.     name[5] = 'd';
  23.  
  24.     printf("when inserted manually: \n");
  25.     printf("%s\n\n\n", name);
  26.  
  27.  
  28.     printf("there are some garbage value when the input was inserted manually. why?\n");
  29.  
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement