|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
Please, look over my code and tell me what I am doing wrong.
The system("pause") is not working, and the program opens and shuts down before I can look at it.
#include <iostream>
using namespace std;
int main ()
{
cout << “Hello World!”;
return 0;
system("pause")
}
3DS Max 9 32Bit
FumeFX
Afterburn
|
|
|
|
use
cin.get();
at the bottom of your command line before you close the function
|
|
|
|
Thank you! You are the MAN! Or woman. Hehe.
Thanks so much.
Oh, um how would I make the text lets say...andy? I know it would deal with the “using namespace std;” But I don’t know what to do after words.
3DS Max 9 32Bit
FumeFX
Afterburn
|
|
|
|
i just need to clarify your question, you want text output to be “Andy” ?
and i would be the MAN=) ty
|
|
|
|
Yes, that would be one of my choices. Right now I’m just messing around with C++. I don’t know much, but I just want to know enough to do some cool things. Andy is what I want to start out with. =]
3DS Max 9 32Bit
FumeFX
Afterburn
|
|
|
|
okay ill explain a couple things to you just so you have an idea of what exactly is going on in that code.
Using namespace std;
is declaring the library, std being “standard library” which is the basic library of syntax (code) in C++.
Where it says “cout>>” think of that has C Output. And beside that is your text; the output. Thats where you want to change your text. “cout” is a standard way in C++ of declaring an ouput. In this case the output is “Hello World”. To get it to say, “Andy”, just type in “Andy” between the quotation marks in your output command line.
basically like this;
cout << “Andy”;
- - - - -
the important thing to learning a programing language is not so much the syntax but more of the fundamentals. Just like 3ds Max or any other 3d rendering program, (even photoshop) its better to learn the different ways/steps to execute the problem rather then focusing on the details of each tiny function in the program. Comptuer programming is essentially problem solving.
|
|
|
|
Ah, damn I said it all wrong. Sorry man. I meant how to change the FONT. I understand the text for the most part, I just want to change the font. If possible. Andy is the font I want, but I have no idea how to change it. I’ve watched a few video tuts on C++ and I’ve got some of the basics down, but not near enough to do anything cool yet. Just some simple text stuff and no strings or functions. So is there a way to change the font?
3DS Max 9 32Bit
FumeFX
Afterburn
|
|
|
|
You cannot change the font as your program is a console application and therefore cannot have different fonts. You can change the colour however.
There are two ways to go about this, firstly you can use a system command which sets the colour of the foreground and background in hexidecimal.
system("COLOR 0d") // makes dos box black background with purple text
Or you could do it like this:
SetConsoleTextAttribute(hOut, BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_RED);
// white background + dark red foreground
The second method is far better as it enables you to have more control and use different colours on the console screen at the same time.
|
|
|
GarrettClem 01 April 2008 09:54 PM
#include <iostream>
using namespace std;
int main ()
{
cout << “Hello World!”;
return 0; <---------------------------- program terminate here
system("pause")
}
|
|
|
|
That was my thought too - the return 0; will terminate the program - but in Garrett’s 2nd posting, he seems to have solved the problem.
Michel (aka Mike)
software engineer by day...3D interest by night
Max v7
hardware: who cares
|
|
|
|
|
|