Jump to content
  • Advertisement
Sign in to follow this  
ritesh024

Ofstream issue

This topic is 3967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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??

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!