I'm newbie in C language, so probably this is a stupid qeustions, but i don't know what to do. this is my trouble:
why this 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 this print the string i 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;
}