View Full Version : Writing to a text file in C++
KronoLeginaire
02-11-2003, 12:35 AM
Please look at the attched c++ source code and tell me how I can fix it to properly write the results to the text file. If you need more explanation let me know.
The program is a CPU loading utility, designed to put heavy mathmatical loads on CPUs to test their performance, not done yet, and will keep adding features but I compile the thing with no errors and it just dose not create/write to the test.txt file. I followed this tutorial here (http://www.cprogramming.com/tutorial/lesson10.html) but then it did not work and I decided to try other approches I found around the internet. Please help.
doctorgonzo
02-11-2003, 02:34 PM
Attached is the fix I made. I made the ofstream variable into a global one, and opened and closed it from within main. It still calls the write procedure to add to the file. I think the problem with your code is that every time you made a call to owriter, it tried to open the output file again, which of course it can't do.
The program seems to loop forever, though maybe I'm just not patient enough.
KronoLeginaire
02-11-2003, 03:08 PM
oh, I got it. Thanks allot!
My problem now may be support, in my way of learning this language I'll need to ask allot of simple questions like 'is there a way to do this' or 'how would i go about doing this' I'm going to try dal-net irc programming channels, the ones on EFNet where no help.
doctorgonzo
02-11-2003, 03:35 PM
Try the tutorials listed here or just Google things. That's how I have picked up my programming, along with going to Half Price Books and getting programming books.
KronoLeginaire
02-13-2003, 11:15 AM
I didn't think that starting a new thread would be wise so I ask you this. How can I start programming GUIs. I want to be able to make a GUI for this CPU brute application, which is being made specificly just to learn the language, so how would I get started making windows and such. From what i've been able to learn on the internet i need some kind of GUI IDE to do this so I have these resources: http://www.objectcentral.com/
V is freeware so I'm thinking its for me, I'm going to upgrade to the latest version of Dev C++ to work with, i was using Visual C++, it went down in flames do I'm going profile.
I get the GUI libs now how can I learn to use them. in the meanwhile I'll be looking around on the site and here.
doctorgonzo
02-13-2003, 11:19 AM
You don't need a GUI IDE to make Win32 apps. I used Dev-C++ and this tutorial to learn about GUI programming in Windows:
http://www.winprog.org/tutorial/
I am just starting out, but the stuff in that tutorial and some other stuff I researched online gave me the knowledge to make a simple text editor. Now that I have Visual Studio, I will learn more about MFC and so forth.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.