Reputation: 4253
I need to copy one file to windir, So I do:
TCHAR windir[MAX_PATH];
GetWindowsDirectory(windir, MAX_PATH);
to get the windir.
char newLocation[]="text.txt"; // how to add the windir here?
BOOL stats=0;
CopyFile(filename, newLocation, stats);
My problem is, I want to add the windir value before the text.txt in char newLocation[].
Any ideas?
Upvotes: 1
Views: 244
Reputation: 73424
Did you try concatenating the strings, like this?
#include <stdlib.h>
#include <string.h>
char* concat(char *s1, char *s2)
{
char *result = malloc(strlen(s1)+strlen(s2)+1);//+1 for the zero-terminator
//in real code you would check for errors in malloc here
strcpy(result, s1);
strcat(result, s2);
return result;
}
If that won't work, give wcscat() a shot!
Sources:
Upvotes: 1