My programs always shut down...

Discussion in 'C++' started by mixy89@gmail.com, Dec 16, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

  2. 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
     
    Nick Keighley, Dec 16, 2005
    #2
    1. Advertising

  3. Jim Langston Guest

    <> wrote in message
    news:...
    > 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;
     
    Jim Langston, Dec 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders Both

    Shut down of asp.net process.

    Anders Both, Jan 11, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    643
    Hermit Dave
    Jan 13, 2004
  2. Michael Persaud

    Shut Down Machine

    Michael Persaud, Jan 22, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    491
    George Ter-Saakov
    Jan 22, 2004
  3. Bruce W.1
    Replies:
    3
    Views:
    408
    Hans Kesting
    Jan 27, 2004
  4. Ken Kolda
    Replies:
    2
    Views:
    491
    Ken Kolda
    May 7, 2004
  5. Steve
    Replies:
    0
    Views:
    468
    Steve
    Jan 31, 2006
Loading...

Share This Page