MSVC++ and outputting statements.
I just recently moved from Java to C++ and currently doing some stuff in VC++. As you people that have been doing applets know, you can easily print String''s to command line. Since my coding experience comes from Java I would love to do this in VC++. Does anyone out there have tips in doing this in VC++? Anything that will show me what the program is up to will be useful.
Thanks.
If your program is a Console program output to the command line (of the console I assume) is normally done through printf (in stdio.h) or cout (in iostream.h). Am I misunderstanding your question? I''m not much of a Java person.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
Hmm, or you could mean the command line literally, which I doubt. But if you do, see system in stdlib.h.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
I don''t really know what I mean since I am so new to VC++. I just need a way to find out what is actually going on while the program is running. It''s not a console app though.
I''ve seen some guys have their game running and on another monitor have printed out statements of what is happening in the game like position of camera and so on. I don''t want to run the game in full screen for now since I don''t have two monitors to work with.
An example application of what I want to do is show exactly what is being added to a linked list.
Output would be: (coordinates have no meaning in this example.
LinkedList::add-> adding (6,5).
LinkedList::add-> adding (3,3).
LinkedList::add-> adding (4,0).
LinkedList::add-> adding (6,3).
It''s a Win32 application. I''m not sure if I am making any sense at the moment but if you have any idea of what I am going on about, please advise.
Thanks again.
I''ve seen some guys have their game running and on another monitor have printed out statements of what is happening in the game like position of camera and so on. I don''t want to run the game in full screen for now since I don''t have two monitors to work with.
An example application of what I want to do is show exactly what is being added to a linked list.
Output would be: (coordinates have no meaning in this example.
LinkedList::add-> adding (6,5).
LinkedList::add-> adding (3,3).
LinkedList::add-> adding (4,0).
LinkedList::add-> adding (6,3).
It''s a Win32 application. I''m not sure if I am making any sense at the moment but if you have any idea of what I am going on about, please advise.
Thanks again.
April 13, 2001 10:57 PM
Well, that depends on what API you''re using. A normal windows app. using the GDI could use DrawText or TextOut. OpenGL app''s normally require you to write the text output (see Nehe''s). I have no idea how to do the DX8 text stuff. Or, you could do what I always do when debugging, and just put it all in a file for viewing later.
That was me, I just forgot to log back in after clearing my browser cache.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
The OutputDebugString function will send a string to the MSVC debugger window (the long window at the bottom, by default). This will update the window as your app executes.
If you want to simply check everything after it has run, just open a text file (i.e., mylog.txt) and write text to the file. Open the text file when the app has closed. Example:
Null and Void: C++ stream I/O is in iostream. The iostream.h file is an older version and is only provided by MSVC for backwards compatibility with its previous compilers. This is the same for all C++ standard library "header" files.
#include <string> // header for std::string
#include <winbase.h> // header for OutputDebugString
using std::string;
int main()
{
// Demostrating strings
string s1 = "hello";
string s2 = "world";
string s3 = s1 + ", logging " + s2 + "!";
// Demostrating debug output
OutputDebugString(s3.c_str());
}
If you want to simply check everything after it has run, just open a text file (i.e., mylog.txt) and write text to the file. Open the text file when the app has closed. Example:
#include <fstream>
using std::fstream;
using std::endl;
int main()
{
// ofstream means "output file stream"
ofstream file("mylog.txt");
// endl means "end line"
file << "hello, logging world!" << endl;
}
Null and Void: C++ stream I/O is in iostream. The iostream.h file is an older version and is only provided by MSVC for backwards compatibility with its previous compilers. This is the same for all C++ standard library "header" files.
Well I guess that shows that I don''t use the C++ i/o stuff then
.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
![](tongue.gif)
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement