I'm just starting to learn c++ and need to know how would you read the first line from a file and write to a new file? thanks
thenewbiecoder
0
Newbie Poster
Recommended Answers
Jump to Postwell you need an ofstream object opened to the file that you want. after you do that in for loop output the char array to the file using the >> operator.
Jump to PostYou have to create the "file1.dat" filename each time through your loop. You need
stringstream
orsprintf
or something similar to do that.
All 5 Replies
Cross213
-5
Posting Whiz in Training
thenewbiecoder
0
Newbie Poster
NathanOliver
429
Veteran Poster
Featured Poster
thenewbiecoder
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.