mercredi 1 avril 2015

what's the difference between array and literal in C?

there's some basic concepts that I get confused when reading a C book recently.


It says: A variable that points to a string literal can’t be used to change the contents of the string.


As I know there's also character literal and integer literal, how's their situation? Are they also can not be update? If so can you give an example?


Besides, what's the difference between literal and array? like character array, string literal, are they actually one thing?


what should I call the variable below? an integer array? an integer literal?


int contestants[] = {1, 2, 3};


I've concluded some examples but I'm still somewhat messed:


char s[] = "How big is it?"; //array variable


char *t = s; //pointer variable to a string literal


string literal:"ABC"


Character literal:'a'


Integer literal:1


Aucun commentaire:

Enregistrer un commentaire