I am trying to concatenate root and absolute path for pset6 but i get extra characters at the start of it but am not sure why.
This is my code:
// concatenate root and absolute-path
char path[strlen(root)+strlen(rqTarget)];
strcat(path,root);
strcat(path,rqTarget);
// ensure path exists
if(access(path, F_OK) !=0 )
{
printf("%s\n",root);
printf("%s\n",rqTarget);
printf("%s\n",path);
error(404);
continue;
}
Terminal window shows this data:
/home/jharvard/Dropbox/pset6/public
/hello.html
��/home/jharvard/Dropbox/pset6/public/hello.html
HTTP/1.1 404 Not Found
I do not understand why i get these extra characters at the start of the path
variable.
Please help.