 |
 |
How do I run command line C++ apps?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: Burlington, IA
Status:
Offline
|
|
I need to know how to run C++ apps through the command line. I write them in pico and compile them using the c++ command but I cannot run them. On my linux server, I run C++ apps by typing ./a.out programname but this gives me an error. I write mostly mathematical apps, like adding all the numbers from 0 to 100 or calculating the position of planets. I would like some help so I can move from my i586 Linux box to OS X on a 500 G3.
------------------
There is no death, there is life. There is no ignorance, there is the Mac.
|
|
There is no death, there is life. There is no ignorance, there is the Mac.
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
What's the error?
./a.out works just fine for me.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: Burlington, IA
Status:
Offline
|
|
Either it gives me a command not found error or it does nothing. I am including a little C++ program I wrote. Maybe I don't have the right headers or something.
#include<iostream.h>
#include<math.h>
main()
{
float i, x, sum;
sum = 0;
cout << "Enter x: ";
cin >> x;
cout << endl;
for ( i=1 ; i<= x ; i++ )
{
sum = sum + i;
}
cout << "The sum of the numbers between 1 and "<<x<<" is: ";
cout << sum;
cout << endl;
return (0);
}
|
|
There is no death, there is life. There is no ignorance, there is the Mac.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Brisbane, Queensland, Australia
Status:
Offline
|
|
#include <iostream> (make sure it has a space).
Originally posted by lonejedi:
Either it gives me a command not found error or it does nothing. I am including a little C++ program I wrote. Maybe I don't have the right headers or something.
#include<iostream.h>
#include<math.h>
main()
{
float i, x, sum;
sum = 0;
cout << "Enter x: ";
cin >> x;
cout << endl;
for ( i=1 ; i<= x ; i++ )
{
sum = sum + i;
}
cout << "The sum of the numbers between 1 and "<<x<<" is: ";
cout << sum;
cout << endl;
return (0);
}
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: Burlington, IA
Status:
Offline
|
|
Nope, still doesn't work. Now it just sits there like it activated the application but won't give the the user prompts.
------------------
There is no death, there is life. There is no ignorance, there is the Mac.
|
|
There is no death, there is life. There is no ignorance, there is the Mac.
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
Aha! The main problem: You need to flush your iostream.
Put a \n at the end of each cout. That'll work.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: Burlington, IA
Status:
Offline
|
|
How do you mean? I tried putting \n in my code like I was taught but I get stray '\' in program errors when I compile. If you could give me a small C++ program that you know works I think it would help.
------------------
There is no death, there is life. There is no ignorance, there is the Mac.
|
|
There is no death, there is life. There is no ignorance, there is the Mac.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|