Ofstream issue

Started by
0 comments, last by Zakwayda 16 years, 2 months ago
hey guys, pls have a look at the code below. " ifstream infile ("A03_wordseg.txt"); ofstream outfile("1.txt"); while(!infile.eof()) { infile.getline(array,100); pch = strtok(array," "); num1 = atoi(pch); if(num1 == -2) { Line_no++; strcpy(filename, "Line_"); itoa(Line_no, Line, 10); strcat(filename, Line); strcat(filename, ".txt"); outfile.close(); ofstream outfile(filename); continue; } pch = strtok(NULL," "); num2 = atoi(pch); outfile<<num1<<" "<<num2<<endl; } " The infile is a text file containing X n Y coordinates. The problem i am facing is that it only writes into 1.txt file N does not write into any other file that is created in d if condition. wen i debugged the code, i saw that wen the outfile is created in d if condition if returns "ofstream vbase destructor".. Can anyone tell why is it happening??
Advertisement
1. This post would probably be most at home in the For Beginners forum.

2. Use [source] tags when posting code.

3. If the program is not too long, post the code in its entirety so we can see everything that's going on.

4. Is this a homework assignment?

5. Is there any particular reason you're using C coding style/techniques/idioms in your C++ code?

This topic is closed to new replies.

Advertisement