Are these the same?

Apr 15, 2011 at 12:49am
Are the following two declarations the same?

char city[] = {'D', 'a', 'l', 'l', 'a', 's'};
char city[] = "Dallas";
Apr 15, 2011 at 1:08am
the first one
char city[] = {'D', 'a', 'l', 'l', 'a', 's'};
will just be a character array as there is no \0 at the end
and
char city[] = "Dallas";
can be said to be a c style string

if you put char
char city[] = {'D', 'a', 'l', 'l', 'a', 's','\0'};
then both will be same
Topic archived. No new replies allowed.