C
Cybex
I am taking a C++ class and would like to use a Linux based IDE vs C+
+ .Net but I am a little lost in how to go about this. I think that
the IDE and compilation tools are separate under Linux. I have tried
to take code written and tested under C++ .Net and tried compiling it
in Linux via gcc but I keep getting errors.
The code:
#include <iostream>
using namespace std;
int main()
{
//declare variables
double score1, score2, score3, average;
//enter inputs
cout << "Enter score for first test: ";
cin >> score1;
cout << "Enter score for second test: ";
cin >> score2;
cout << "Enter score for third test: ";
cin >> score3;
//display outputs
if (score1 >= 0 && score2 >= 0 && score3 >= 0)
{
average = (score1 + score2 + score3) / 3;
cout << "The average for the three test is: "
<< average << "\n";
}
else
cout << "You must enter a score for each test"
<< "equal to or greater than zero." << "\n";
return 0;
} //end of main function
The errors:
user@user1:~$ gcc -o /home/user/test.out /home/user/testing.c
/home/user/testing.c:1:20: error: iostream: No such file or directory
/home/user/testing.c:3: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'namespace'
/home/user/testing.c: In function 'main':
/home/user/testing.c:11: error: 'cout' undeclared (first use in this
function)
/home/user/testing.c:11: error: (Each undeclared identifier is
reported only once
/home/user/testing.c:11: error: for each function it appears in.)
/home/user/testing.c:12: error: 'cin' undeclared (first use in this
function)
Any help on how I can accomplish my assignments in Linux vs Windows
would be appreciated. I am having to use VMWare now in order to use
the C++ >Net IDE.
James
+ .Net but I am a little lost in how to go about this. I think that
the IDE and compilation tools are separate under Linux. I have tried
to take code written and tested under C++ .Net and tried compiling it
in Linux via gcc but I keep getting errors.
The code:
#include <iostream>
using namespace std;
int main()
{
//declare variables
double score1, score2, score3, average;
//enter inputs
cout << "Enter score for first test: ";
cin >> score1;
cout << "Enter score for second test: ";
cin >> score2;
cout << "Enter score for third test: ";
cin >> score3;
//display outputs
if (score1 >= 0 && score2 >= 0 && score3 >= 0)
{
average = (score1 + score2 + score3) / 3;
cout << "The average for the three test is: "
<< average << "\n";
}
else
cout << "You must enter a score for each test"
<< "equal to or greater than zero." << "\n";
return 0;
} //end of main function
The errors:
user@user1:~$ gcc -o /home/user/test.out /home/user/testing.c
/home/user/testing.c:1:20: error: iostream: No such file or directory
/home/user/testing.c:3: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'namespace'
/home/user/testing.c: In function 'main':
/home/user/testing.c:11: error: 'cout' undeclared (first use in this
function)
/home/user/testing.c:11: error: (Each undeclared identifier is
reported only once
/home/user/testing.c:11: error: for each function it appears in.)
/home/user/testing.c:12: error: 'cin' undeclared (first use in this
function)
Any help on how I can accomplish my assignments in Linux vs Windows
would be appreciated. I am having to use VMWare now in order to use
the C++ >Net IDE.
James