It works no problem?
Code:
#include <stdio.h>
struct foo {
char s1[5];
char s2[5];
};
int main(void)
{
struct foo bar = { "" , "" };
gets(bar.s1);
printf(" s1 = \"%s\"\n s2 = \"%s\"\n", bar.s1, bar.s2);
return 0;
}
/*
C:\Documents and Settings\User>a
12345678
s1 = "12345678"
s2 = "678"
*/
Clearly this is just flawless... why was s2 allowed to be changed?
fgets is not rocket science:
Code:
resultptr = fgets( storage, howmanycharacters, fromfile );
It's easy to use and safe, please figure it out or just stop using C...