I'm a beginner in C++ and I wrote this simple code:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
usingnamespace std;
int main()
{
int base, exponent;
cout << "Enter two numbers" << endl;
cin >> base >> exponent;
cout << "Your numbers are: " << base << " " << exponent << endl;
return 0;
}
is it a compiler issue? I compile and run the code using:
1 2
g++ code.cpp
./a.out
and the output is:
1 2
Enter two numbers
Your numbers are: 0 0
Edit: I figured the issue, it has nothing to do with c++ but with the noevim editor, I compile and run the code from within neovim and it doesn't accept user input. Running a.out from the terminal solves the issue.
Thank you for your help, I figured the issue, it has nothing to do with c++ but with the noevim editor, I compile and run the code from within neovim and it doesn't accept user input. Running a.out from the terminal solved the issue.
What found is that following #include <iostream> there are unnecessary spaces in the file. Not that this will cause any problems.
I am not familiar with "noevim", but as I understand "g++" the compiler generates ".a" files that are then linked with any other needed files to form the ".exe" program. At least that is my understanding.