Hi, I am kinda new to c and i've encountered a problem with
program because i need to change a constant. I ofcourse don't
want to change a constant so is there any way to convert a
constant to a variable? I've tried something with malloc but
it didn't work for me. Here's what i tried:
char *url;
char *filename;
char *tmpstring;
url = strtok(header, " ");
url = strtok(NULL, " ");
puts (url);
//tmpstring = (char *)malloc(sizeof (SERVER_ROOT)*s trlen(SERVER_RO OT));
tmpstring = (char *)malloc(1000);
tmpstring = SERVER_ROOT;
//strcat (url, SERVER_ROOT);
filename = strcat(tmpstrin g, url);
puts (url);
as you can see i am trieing to combine SERVER_ROOT and url to
get something like /var/www/html/news.html where SERVER_ROOT
is /var/www/html and url = /news.html
Can anyone please help me?
Thanks in advance,
Robert
program because i need to change a constant. I ofcourse don't
want to change a constant so is there any way to convert a
constant to a variable? I've tried something with malloc but
it didn't work for me. Here's what i tried:
char *url;
char *filename;
char *tmpstring;
url = strtok(header, " ");
url = strtok(NULL, " ");
puts (url);
//tmpstring = (char *)malloc(sizeof (SERVER_ROOT)*s trlen(SERVER_RO OT));
tmpstring = (char *)malloc(1000);
tmpstring = SERVER_ROOT;
//strcat (url, SERVER_ROOT);
filename = strcat(tmpstrin g, url);
puts (url);
as you can see i am trieing to combine SERVER_ROOT and url to
get something like /var/www/html/news.html where SERVER_ROOT
is /var/www/html and url = /news.html
Can anyone please help me?
Thanks in advance,
Robert
Comment