I'm having problems with some codes in C:
char opt, name[10], path[25];
printf("Things\nMore things\n");
printf("Even more things\n");
printf("\nChar: ");
scanf("\n%c",&opt);
printf("\nTask name: ");
scanf("%s",name);
printf("Name: %s\n", name);
printf("\nFolder name: ");
scanf("%s",path);
printf("Name: %s\n", name);
printf("Path: %s\n", path);
This is the code that makes trouble in a "clean" mode. The problem is that, when size of data is bigger than 10 or 25, then, instead of cutting the string, it mixes "name" and "path". It has even put part of "path" into "name" in some cases. Is this undefined behaviour, or I am missing something?
%10sto address this, but the rules are icky. Read your friendly scanf man page!