»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 02-16-2004, 01:10 PM   #1 (permalink)
Registered User
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 3,962
Creatures is on a distinguished road
Send a message via ICQ to Creatures
C++ reading from file...

ok i just created this little program:

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{

    char buffer[255], file[255], text[255];
    
    cout << "Filename: ";
    cin.getline( buffer , 255);
    strcpy(file, buffer);
    cout << "Text: ";
    cin.getline( buffer,255);
    strcpy(text, buffer);
    system("pause");

    ofstream oFile(file,ios::app);

    if (! oFile)
    {
        cout << "Somethings wrong..." << endl;
        return -1;
    }
    oFile << text << endl;
    oFile.close();
    
    return 0;
}
this program creates always a new line and inserts the char text, now i want to read and output just one of those lines, but i have no idea how i should do this

i thought about adding a sign at the end of each line to mark new lines, but i donnu how to find this mark again!

can anyone help?

Creatures

__________________
___)
(
____)REATURES
Creatures is offline   Reply With Quote
Old 02-17-2004, 02:32 PM   #2 (permalink)
Registered User
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 3,962
Creatures is on a distinguished road
Send a message via ICQ to Creatures
little bump

Creatures
__________________
___)
(
____)REATURES
Creatures is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 05:59 PM.