String Error

Hey Guys,

I'm making a installer of some sort that just copies files from one place to another. But, on the last line, the 'string' gets and error that I just can't get rid of. I'm really annoyed now, can someone PLEASE HELP?

Thanks,

darth_layto.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "stdafx.h"
#include <string>
#include <windows.h>

using namespace std;

int main()
{
	string Input = "C:\\users\Jacob\Documents\Visual Studio.exe";
	string CopiedFile = "Visual Studio.exe";
	string OutputFolder = "C:\\users\Jacob\Desktop";

	CopyFile(Input.c_str, string(OutputFolder + CopiedFile).c_str(), TRUE);
}
Last edited on
The backslash character is used for escape sequences. If you want a backslash in a string you'll have to put it twice in a row.
 
string Input = "C:\\users\\Jacob\\Documents\\Visual Studio.exe";

But why not use forward slash? It works on Windows and is the delimiter used by most other operating systems.
 
string Input = "C:/users/Jacob/Documents/Visual Studio.exe";
Last edited on
The error message is probably because you forgot to use parentheses after the first c_str on line 13.
Topic archived. No new replies allowed.