View Single Post
  #3   Spotlight this post!  
Unread 22-08-2006, 16:23
Noah Kleinberg Noah Kleinberg is offline
Registered User
FRC #0395 (2TrainRobotics)
Team Role: Driver
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 196
Noah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to behold
Send a message via AIM to Noah Kleinberg
Re: Data From C++ GUI to Excel/Notepad, Application Trouble

Quote:
Originally Posted by TomS
"Hi,
I need to get data from a C++ application to a spread sheet or notepad file, has anyone any idea how to do this. I have access to programme source code but not sure where to start."
A "notepad file" would be easier to output to than a spread sheet, which would require you to research the file-format.

To output to a file from a C++ program, you have a few choices.

1) The program can output all of the data you need to a command line, and then when you run the program run it as:

your_program.exe > file_with_data.txt

The ">" tells the command line to take all of the text that was outputted to stdout (which is what cout and printf do) and put it into the file following the ">" sign, in this case "file_with_data.txt"

2) There is a standard library for outputting to files for C++ from within the program. It's called 'fstream', so you would put "#include <fstream>" at the beginning of your program.

To use this, you would need to make an fstream object at the beginning of your program, and then use it like "cout" to output data. Here's an example:

Code:
fstream file_output; // create an 'fstream' object
file_output.open("my_filename.txt"); // open the file 'my_filename.txt'
//whenever you want to output data:
file_output << "This goes into the file";
//and at the end to close the file:
file_output.close();
You could google 'fstream' or 'file i/o tutorial' for more/better help.

Hope that was clear, good luck