strings in C, (i'm newbie in C) -
this question has answer here:
- assigning string string 5 answers
i'm newbie in c language, stupid qeustions, don't know do. trouble:
why code doesn't print nothing?
#include <stdio.h> #include <stdlib.h> void function(char* valor); main() { char* valor; int s; valor=(char*)malloc(101*sizeof(char)); function(valor); printf("%s\n",valor); return 0; } void function(char* valor) { valor="ciao"; } and print string want? ("ciao")
#include <stdio.h> #include <stdlib.h> main() { char* valor; valor=(char*)malloc(101*sizeof(char)); valor="ciao"; printf("%s\n",valor); return 0; }
the variable valor inside function , variable valor in main different variables.
when change value of valor inside function, nothing happens valor in main.
Comments
Post a Comment