My programs always shut down...

M

mixy89

Hi guys...

I'm really new to the language of scripting, and therefore i am trying
to make som really really simple programs. But nomatter what when i run
the program, it finishes its "job" then it just shuts down. This is
really stupid, as i cant see what the program does before it shuts down
:p

Another problem i got is that i cant seem to be able to multiply
anything... When do the compiling it says - invalid type argument of
`unary *' - Any ideas how i can make this work? Thanks alot folks :D
 
N

Nick Keighley

I'm really new to the language of scripting,

C++isn't normally regarded as a scripting langauge
and therefore i am trying
to make som really really simple programs. But nomatter what when i run
the program, it finishes its "job" then it just shuts down.

you don't say what environment you are using. I'm guessing it's a
Window's
PC. If so the program executes in a "DOS" window which terminates when
the program terminates. Try a Windows group for more information. As a
hack try putting this line at the end of your program
getchar ();

and put
#include <stdio.h>
at the beginning of the program

there are better ways of doing this in C++ but it might let you see
your
program's output
This is
really stupid, as i cant see what the program does before it shuts down
:p

Another problem i got is that i cant seem to be able to multiply
anything... When do the compiling it says - invalid type argument of
`unary *' - Any ideas how i can make this work? Thanks alot folks :D

post your code. Note that multiply needs two arguments

a = b * c;
 
J

Jim Langston

Hi guys...

I'm really new to the language of scripting, and therefore i am trying
to make som really really simple programs. But nomatter what when i run
the program, it finishes its "job" then it just shuts down. This is
really stupid, as i cant see what the program does before it shuts down
:p

I always add this to the bottom of my main when I have that problem.

std::string Temp;
std::cin >> Temp;

This basically just waits for input from the keyboard terminated with a
carriage return before the program ends (and the console closes). You need
Another problem i got is that i cant seem to be able to multiply
anything... When do the compiling it says - invalid type argument of
`unary *' - Any ideas how i can make this work? Thanks alot folks :D

Multiplication takes two operands, a left hand and a right hand. The
"normal" syntax for mulitplication would be:
a = b * c;
a = 1 * b;
a = b * 3.14159f; // the f means float Without the f it's a double
a *= b; // a = a * b;
a *= 2.0; // a = a * 2.0;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top