0

chan someone help me see this problem? its closed and everything.

string notename;
x = 1;

cout << notename[x] << endl;
if(remove(notename[x].c_str()) != 0)
{
perror( "Error deleting file" );
}
else
{
cout << "File successfully deleted";
}
2
Contributors
1
Reply
17
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
0

line 5 is wrong -- notename[x] is a single character and c_str() returns a string. Maybe line 1 is incorrect -- string notename[10]; which would mean notename is an array of string objects.

string notename = "filename.txt";
x = 1;

cout << notename << endl;
if(remove(notename.c_str()) != 0)
{
perror( "Error deleting file" );
}
else
{
cout << "File successfully deleted";
}

Edited by Ancient Dragon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.