Friday, 23 August 2013

How to initialize a char array using a char pointer in C

How to initialize a char array using a char pointer in C

Let's say I have a char pointer called string1 that points to the first
character in the word "hahahaha". I want to create a char[] that contains
the same string that string1 points to.
How come this does not work?
char string2[] = string1;

No comments:

Post a Comment