I'm having problems with scanf
in C. After reading other Stackoverflow posts on how to fix problems with scanf
, I now know that scanf
is not recommended, but I have to use it for a homework assignment. I am trying to store 3 string values that have a maximum size according to their buffer size. When I compile and run this program, I input the values 255 255 255
and this is what is printed.
1:
2:
3: 255
Here is the program source:
#include <stdio.h>
int main(){
char first[8] = "", second[3] = "", third[3] = "";
scanf("%8s %3s %3s", first, second, third);
printf("1: %s\n2: %s\n3: %s", first, second, third);
}