fstream f;
char ch;
int i=0;
string word,word2[200];
f.open("op3_sort.txt",ios::in|ios::out);
if(!f) cout<<"\nUnable To Open File!\n";
else
{
cout<<"\nLet's View D Content!\n";
while(!f.eof())
{
getline(f,word,'\t');
word2[i]=word;
i++;
cout<<word2[i];
}
}
cout<<"\nShowing Data Now\n";
for(int a=0; a<i; a++)
{ cout<<endl;
cout<<word2[a];
}
devourer17
0
Newbie Poster
Recommended Answers
Jump to PostWhat do you mean by "line spaces"? It could mean a couple of things in this context, could you clarify please? :)
Jump to Postis it possible that there is whitespace in your file that has a tab after it? Or a tab and then a newline? That would cause you to get empty lines showing up
Jump to PostIf you were to use stringstream objects, your file conversion from ..
7 regular data 'words' on each line ...
to ...
all 7 sequential words on their own sequential line,
(with the exception that the 2nd and 3rd words are both on the 2nd line, separated by one space) …
All 9 Replies
devourer17
0
Newbie Poster
devourer17
0
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
devourer17
0
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
devourer17
0
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
David W
131
Practically a Posting Shark
devourer17
0
Newbie Poster
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.