##### main{ char str[10]; str="abcde"; } is

main{

char str[10];

str="abcde";

}

is the second line a valid initialisation of string if not what is the valid initialisation.

##### 1Comment
Ranita Biswas
10 Jan 2015 06:55 pm

No, it's not a valid initialization.
You can choose any one of the following valid initializations of character array:

char str[10] = "abcde";

char str[10] = {'a','b','c','d','e'};

char *str;
str="abcde";

In the third case, you will get a constant string, which you cannot modify later.