deleting a line from text file

i know you the steps i have to take to do it
open file
copy everything but line i want to delete to temp file
delete original
rename temp to original

but i dont know how to find the line
i have tried getline but this error comes up

main.cpp|74|error: no matching function for call to `getline(std::ifstream&, char[1])'|

i have also tried file.read

but it just deletes the entire file.

what other things can i do.
That particular getline() takes an std::string & as its second parameter.
oh ok thanks helios
i have figured you how to delete a line what i want to know how to delete the line above along with it automatically.

this is the code i have for deleting the string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ifstream sup;
    sup.open("supplies.txt");
    ofstream temp;
    temp.open("temp.txt");
    cout << "what supply do you want to remove? ";
    cin >> deleteline;
    while (getline(sup,line))
    {
        if (line != deleteline)
        {
            temp << line << endl;
        }
    }
    temp.close();
    sup.close();
    remove("supplies.txt");
    rename("temp.txt","supplies.txt");
    cout <<endl<<endl<<endl;


now what im thinking is to find the line number then munus it by one and delete that one also.
Topic archived. No new replies allowed.