Hello everyone,
I am a beginer of C programming and have a short question here.
I declared my variables as bellow in the main method.
char a[10];
char b[25];
char c[25];
char d[5];
char e[3];
scanf("%s%s%s%s %s",a,b,c,d,e );
printf("%s\t%s\ t%s\t%s\t%s\t", a,b,c,d,e);
when I do the scanf, my inputs are
a
b
c
A80
P01
(I have them in the same line when I input the values, here just for make them more clearly to read.)
My problem is that after the printf() executed, the outputs are
a
b
A80
P01.
The variable c is supposed not to be null. It should have its own value, which is 'c' in this case. I am wondering what causes the null pointer and what is the solution?
Your help will be mostly gratitude. Thanks all in advance.
I am a beginer of C programming and have a short question here.
I declared my variables as bellow in the main method.
char a[10];
char b[25];
char c[25];
char d[5];
char e[3];
scanf("%s%s%s%s %s",a,b,c,d,e );
printf("%s\t%s\ t%s\t%s\t%s\t", a,b,c,d,e);
when I do the scanf, my inputs are
a
b
c
A80
P01
(I have them in the same line when I input the values, here just for make them more clearly to read.)
My problem is that after the printf() executed, the outputs are
a
b
A80
P01.
The variable c is supposed not to be null. It should have its own value, which is 'c' in this case. I am wondering what causes the null pointer and what is the solution?
Your help will be mostly gratitude. Thanks all in advance.
Comment