Wednesday, 15 February 2012

c - Char array, why must I "dereference" a string of a single character to assign it -



c - Char array, why must I "dereference" a string of a single character to assign it -

int main() { char test[15] = "hallo world"; test[1] = *"e"; }

to alter 2nd letter e, have deference string "e". couldn't find info why so. if don't dereference string "e", test ends becoming "h$llo world". enlighten me?

a character literal in c spelled apostrophes:

test[1] = 'e';

of course of study go through number of obfuscating, complex expressions produce character value, direct , deliberate way accomplish intended behaviour.

c string char

No comments:

Post a Comment