c - How can I change the value where char* is Pointing? -


i using char* store variable values, there's problem can't change value. if suggest method..... life saver me....

char* year=""; //definition empty get_data(){   year=  //"here want give value of variable(also in char*)" } 

the short answer (don't this):

#include <string.h> ... strcpy(year, "your new string"); 

the reason not don't own memory year pointing to. instead, should declare year char year[100], allocates memory on stack. can copy string it.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -