cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
how would i remove the first line in a t
how would i remove the first line in a txt file
May 31, 2014 at 7:01pm UTC
ProgramMaster
(77)
Alright i have a txt file and i am making a program to open it and read from it but is their a way to make a section that will delete the top line in the file
so if the txt file containted
Hello
bye
what
you
after the program the file would read
bye
what
you
Last edited on
May 31, 2014 at 7:02pm UTC
May 31, 2014 at 7:25pm UTC
closed account (
j3Rz8vqX
)
Open file for reading.
Read the data into your array of strings.
Close reading file.
Modify the first string in the array @ index 0 to be ""; null.
Open file for writing.
Write your data into file; truncating.
Close write file.
Done.
http://www.cplusplus.com/doc/tutorial/files/
Ensure to write out with the
ios::trunc
option.
Topic archived. No new replies allowed.