Yes, c[i]=''
is not a valid code. We parenthesis character constant between '
'
, e.g. c[i] = 'A';
char A
. but you don't write any char in between ''
.
Empty space is nothing but suppose if you wants to assigned space then do:
c[i] = ' ';
// ^ space
if wants to assigned nul char
then do:
c[i] = '\0';
// ^ null symbol
Example: Suppose if c[]
a string (nul \0
terminated char array) if you having a string. for example:
char c[10] = {'a', '2', 'c', '\0'};
And you replace second char with space:
c[1] = ' ';
and if you print it using printf as follows:
printf("\n c: %s", c);
then output would be:
c: a c
// ^ space printed
And you replace second char with '\0':
c[1] = '\0';
then output would be:
c: a
because string terminated with \0
.