By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,330 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,330 IT Pros & Developers. It's quick & easy.

My programs always shut down...

P: n/a
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

Dec 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mi****@gmail.com wrote:
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;
--
Nick Keighley

Dec 16 '05 #2

P: n/a

<mi****@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
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
to #include <iostream> to use std::cin though and #include <string> for
std::string
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;
Dec 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.