Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1.     char my_string[13];  // should create a 12 byte string with a \0 in 13th byte
  2.     my_string[12] = '1';  // should update character '1' into the 12th position, \0 remains in 13th
  3.     printf("%s\n", my_string);  // but this prints blank?
  4.    
  5.     // I want to try and iterate over the string changing the character in position 12
  6.     for (int i = 0; i < 10; i++)
  7.     {
  8.         my_string[12] = my_string[12] + 1;
  9.         printf("%s\n", my_string);  // but this just prints a blank string
  10.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement