Brando753
November 12th, 2009, 01:41 AM
Ive been trying to write programs in C++ for a programming class, rather then using the windows application, however, the programs that compile fine in windows do not in ubuntu. Tried both Monodevelop & MinGW for linux. Here is a copy of the code.
//Hello World
#include <iostream>
void main()
{
//Declare and initialize variables
short num = 0;
short numCubed = 0;
//enter input item
cout << "enter a number between 1 and 20: ";
cin >> num;
//call function to cube number
numCubed = cube(num);
//display output item
cout << "the cube is " << numCubed << end1;
}
//end of main function
Tried both <iostream.h> and <iostream> and get these errors
Compiling source to object files
gcc -MMD "/home/brandon/Projects/Hello World/Hello World/starter.c" -g -O0 -DDEBUG -DMONODEVELOP -I"/home/brandon/Projects/Hello World/Hello World/.prec/Debug" -c -o "/home/brandon/Projects/Hello World/Hello World/bin/Debug/starter.o"
/home/brandon/Projects/Hello World/Hello World/starter.c:4:20: warning: iostream: No such file or directory
/home/brandon/Projects/Hello World/Hello World/starter.c: In function ‘main’:
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: ‘cout’ undeclared (first use in this function)
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: (Each undeclared identifier is reported only once
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: for each function it appears in.)
/home/brandon/Projects/Hello World/Hello World/starter.c:14: error: ‘cin’ undeclared (first use in this function)
/home/brandon/Projects/Hello World/Hello World/starter.c:20: error: ‘end1’ undeclared (first use in this function)
Build complete -- 5 errors, 0 warnings
If someone could tell me what I did wrong, and what the differences between programming in windows vs Ubuntu is. Why if it works in windows dosent it work in ubuntu, its the same language right?
Help Anyone? Thanks in advance.
//Hello World
#include <iostream>
void main()
{
//Declare and initialize variables
short num = 0;
short numCubed = 0;
//enter input item
cout << "enter a number between 1 and 20: ";
cin >> num;
//call function to cube number
numCubed = cube(num);
//display output item
cout << "the cube is " << numCubed << end1;
}
//end of main function
Tried both <iostream.h> and <iostream> and get these errors
Compiling source to object files
gcc -MMD "/home/brandon/Projects/Hello World/Hello World/starter.c" -g -O0 -DDEBUG -DMONODEVELOP -I"/home/brandon/Projects/Hello World/Hello World/.prec/Debug" -c -o "/home/brandon/Projects/Hello World/Hello World/bin/Debug/starter.o"
/home/brandon/Projects/Hello World/Hello World/starter.c:4:20: warning: iostream: No such file or directory
/home/brandon/Projects/Hello World/Hello World/starter.c: In function ‘main’:
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: ‘cout’ undeclared (first use in this function)
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: (Each undeclared identifier is reported only once
/home/brandon/Projects/Hello World/Hello World/starter.c:13: error: for each function it appears in.)
/home/brandon/Projects/Hello World/Hello World/starter.c:14: error: ‘cin’ undeclared (first use in this function)
/home/brandon/Projects/Hello World/Hello World/starter.c:20: error: ‘end1’ undeclared (first use in this function)
Build complete -- 5 errors, 0 warnings
If someone could tell me what I did wrong, and what the differences between programming in windows vs Ubuntu is. Why if it works in windows dosent it work in ubuntu, its the same language right?
Help Anyone? Thanks in advance.