LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   G++ compiles fine but program does not work (https://www.linuxquestions.org/questions/programming-9/g-compiles-fine-but-program-does-not-work-170678/)

MaddDog696 04-15-2004 05:29 PM

G++ compiles fine but program does not work
 
ok, here is the question; I am pretty familiar with C++ and have been programmig with it in windows for while awhile using DJGPP and dev-C++. I also have been using linux (redhat 9) for awhile as well, and decided to try programming in it. I busted out gedit and wrote this basic code:

Code:

#include <iostream>
using namespace std;

int main()
{
short int x;
cout << "enter a num: ";
cin >> x;
cout << "\nYou entered " << x;
return 0;
}

END


I compiled it using G++ like this

#G++ -o test ./entrnum.cpp

It compiles it and saves it to program 'test', as i told it to. however when i run the program like so:

#test

nothing happens. it just goes to the input command line again as it i never did anything. I would expect that the program listed above, when run through the command line, shoule execute through the terminal and, as in the program, start off with, "enter a num; ". why is nothing happening when i run my program? did i do something wrong in the code, or execute it wrong. i am at a loss of where to go from here. if there is no error report i cannot see what is wrong. i dont think that the code is wrong but please help. it is kind of frustrating. thanx :)

-MaddDog

lazyboy0001 04-15-2004 05:32 PM

try
./test

MaddDog696 04-15-2004 05:35 PM

Wow, that was easy, thanx so much. I feel slow, lol

-MaddDog

--Linux questions rox

lazyboy0001 04-15-2004 05:39 PM

By the way, test is a linux shell command. Try to name your exe file another name


All times are GMT -5. The time now is 12:05 PM.