#include <stdio.h>
#include <string.h>
main()
{
char s[2][3];
int c;
for( c = 0 ; c < 2 ; c++ )
{
printf("Your %d string: ", c);
scanf("%s", s[c]);
if( strlen(s[c]) > 3 )
{
c--;
printf("More than 3 characteres!\n");
continue;
}
}
return 0;
}
Question:
Whenever the user enter more than 3 characters which exceeds
the allocated space, this program will prompt the user to reenter their desire string. But the problem is when I purposely enter more than 3 characters in second attempt, the compiler prints
out as usual but with error windows pop up. I know this error was due to over-stored characters. So, is there any function that can clear that particular array and treat is as new one or maybe there is other way of doing so?