some help w/ this cpp prog??

cHeeZeFacTory

Golden Member
Apr 23, 2001
1,658
0
0
I want to write a prog ( in cpp) that reads in a text file w/ this:

a1908
b0980
r09809
...

to this:

a1908;b0980;r09809;...

I know it is simple, but i haven't programmed in a real long time. TIA!!
 
Dec 13, 2003
80
0
0
So you want to take a file consisting of entries, one per line, and have them instead be separated by a semicolon?

cat originalfile.txt | sed 's/\n/\;/g' > newfile.txt

No programming required.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
fread or fget to the end of line, strip the newline and replace it with a semicolon, then continue the look until you hit EOF.

cat originalfile.txt | sed 's/\n/\;/g' > newfile.txt

No programming required.

Dumbass - he said he has to do it in C (well c++, but nothing in c++ says you can't use plain C).