Computer Science, asked by roshanrs296, 1 year ago

What is missing in this string initialization: char name[8] = { ‘r’, ‘a’, ‘e’, ‘t’}

Answers

Answered by DeekshithChennuri
1
In my perspective a semicolon at the end is missing
Answered by amikkr
1

Correct initialization is : char name[8] = {'r','a','e','t','\0'} ;

This is the correct representation for declaring a string in C.

  1. For a string array representation in C, the initialization must be terminated by a null character at the end of the initialization and must be terminated by a semicolon at the end of the statement or declaration.
  2. Another way of declaring the array is: char name[] = {'r','a','e','t','/0'};
  3. This initialization declares dynamic string where the length of the string is determined automatically by the array declaration.  

Similar questions