lundi 1 septembre 2014

store string in char array assignment makes integer from pointer without a cast


Vote count:

0





#include <stdio.h>

int main(void){
char c[8];
*c = "hello";
printf("%s\n",*c);
return 0;
}


I am learning pointers recently. above code gives me an error - assignment makes integer from pointer without a cast [enabled by default]. I read few post on SO about this error but was not able to fix my code. i declared c as any array of 8 char, c has address of first element. so if i do *c = "hello", it will store one char in one byte and use as many consequent bytes as needed for other characters in "hello". Please someone help me identify the issue and help me fix it. mark



asked 1 min ago







store string in char array assignment makes integer from pointer without a cast

Aucun commentaire:

Enregistrer un commentaire