How do we remove a file

i want to remove a file.
The name is stored in a string.
remove() seems not to be working
what does perror() say
1
2
3
4
5
6
7
8
9
10
string Index;


cout << "\tNAS:";
getline(cin, strNAS);
Index="c:\\Bonsanghistan\\index\\"+strNAS+".txt";
ofstream of(Index,ios::out); // created it in a fonction before removing it 

remove((const char*)&Index);
perror("The following error occurred");


The following error occurred: No such file or directory


My program created the file with Index also so how can't it be found...
And i see the file int my repertory
Last edited on
So you've got an error about invalid types, and you decided to cast.
remove( Index.c_str() );
Thanks man it successful didn't know string add that function
Last edited on
Topic archived. No new replies allowed.