• Welcome to Valhalla Legends Archive.
 

Does this work?

Started by muert0, July 03, 2004, 09:14 PM

Previous topic - Next topic

muert0

I have this:
   #include <iostream.h>
int          
main()
{
 int thisisanumber;
 cout<<"Please enter a number:";
 cin>>thisisanumber;
 cout<<"You entered: "<<thisisanumber;
 return 0;
}

When I run it I get a  line that says Please enter a number:
I enter a number and the prompt closes.
I tryed doing this and got an error:
     #include <iostream.h>
     #include <stdlib.h>
int
main()
{
 int thisisanumber;
 cout<<"Please enter a number:";
 cin>>thisisanumber;
 cout<<"You entered: "<<thisisanumber;
 system("PAUSE");
 return 0;
}

Is this way off?
To lazy for slackware.

Moonshine

Quote from: muert0 on July 03, 2004, 09:14 PM
I have this:
   #include <iostream.h>
int          
main()
{
 int thisisanumber;
 cout<<"Please enter a number:";
 cin>>thisisanumber;
 cout<<"You entered: "<<thisisanumber;
 return 0;
}

When I run it I get a  line that says Please enter a number:
I enter a number and the prompt closes.
I tryed doing this and got an error:
     #include <iostream.h>
     #include <stdlib.h>
int
main()
{
 int thisisanumber;
 cout<<"Please enter a number:";
 cin>>thisisanumber;
 cout<<"You entered: "<<thisisanumber;
 system("PAUSE");
 return 0;
}

Is this way off?

It doesn't look like you're using normal quotes ("")...

muert0

Cool it took me a minute to figure out what you were saying. Thanks for the help.
To lazy for slackware.

Adron

Actually, the prompt closing after entering the number is normal. Having a pause there is useful when debugging, but generally, you don't want a pause when a console application finishes. Try running it from a cmd console, and you'll see.

muert0

Ok I had to go dig around in console mode for a while and remeber how to navigate around in it. Heh, I kept typing ls instead of dir. Oh well what's the command to run the program? I went to the directory the file was in and typed run project 2.exe. And it said run wasn't a valid command.
To lazy for slackware.

Adron

Just type the name of your exe file. If it's named with a space in it, you have to surround the command with quotes. The exe extension is optional.

c:\projects\project 2\release>"project 2"


muert0

Ok that does make a lot more sense. thanks for the help.
To lazy for slackware.

UserLoser.

QuoteDoes this work?

You said there's an error, so no.