Antutu Cat
Antutu Cat

Reputation: 105

Access character arrays in C

why I can not assign it like this:

char c1 []="Odin";
   c1=c1+1;

Note that I include

#include<string.h>

Upvotes: 1

Views: 45

Answers (1)

Zoso
Zoso

Reputation: 3465

Quoting the reference for your problem:

Assignment Objects of array type cannot be modified as a whole: even though they are lvalues (e.g. an address of array can be taken), they cannot appear on the left hand side of an assignment operator:

So, since c in your code is an array object i.e. a type of an array, it cannot appear on the left-hand side of an assignment operator.

Upvotes: 1

Related Questions