#include<stdio.h>
# define A 10
const short LINE_SIZE = 255;
main(){
char a[LINE_SIZE + 1] = " "; //Error here...why is this an error??
char b[A]=""; //no problem here
printf("%d",sizeof(a));
printf("%s",a);
}
nikileshsa
0
Newbie Poster
Recommended Answers
Jump to PostThe first line puts a space into the first char of a, and a zero into the second char. All other elements of a are uninitialised. Hence the compiler diagnostic (which will usually be a warning, not an error).
The second line initialises the array b with a zero …
All 3 Replies
grumpier
149
Posting Whiz in Training
Narue
5,707
Bad Cop
Team Colleague
grumpier
149
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.