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 6 10797
Cybex wrote:
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)
not sure but looks like the compiler was compiling C code not C++
(mistakenly.) Why not try g++ instead of gcc.
>
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.
For a standard ISO C++ program any tool would be fine.
>
James
Ben
That worked like a charm! Thanks
gcc was the only tool I found reference to in a Linux for programmers
book that talked about C/C++. So doing things this way should work
right? Is C++ the same across the two platforms? This is an intro to
C++ so I doubt we will get very far beyond the basics.
James
Cybex wrote:
That worked like a charm! Thanks
gcc was the only tool I found reference to in a Linux for programmers
book that talked about C/C++. So doing things this way should work
right? Is C++ the same across the two platforms? This is an intro to
C++ so I doubt we will get very far beyond the basics.
James
The "GCC" Collection includes the "gcc" compiler for C and
the "g++" compiler for C++. Always compile -and- link
C++ programs using "g++".
Cybex wrote:
That worked like a charm! Thanks
gcc was the only tool I found reference to in a Linux for programmers
book that talked about C/C++. So doing things this way should work
right? Is C++ the same across the two platforms? This is an intro to
C++ so I doubt we will get very far beyond the basics.
James
The newsgroup for the GCC 'C' compiler is
gnu.gcc.help
The newsgroup for the GCC 'C++' compiler is
gnu.g++.help
On 1ÔÂ30ÈÕ, ÉÏÎç11ʱ29·Ö, Larry Smith <lsm...@nospam. comwrote:
Cybex wrote:
That worked like a charm! Thanks
gcc was the only tool I found reference to in a Linux for programmers
book that talked about C/C++. So doing things this way should work
right? Is C++ the same across the two platforms? This is an intro to
C++ so I doubt we will get very far beyond the basics.
James
The newsgroup for the GCC 'C' compiler is
gnu.gcc.help
The newsgroup for the GCC 'C++' compiler is
gnu.g++.help
Be sure your GCC installation is correct, also , change your file name
test.c to test.cpp
Cybex wrote:
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.
Rename to testing.cpp, compile with g++. Otherwise you risk
the compiler thinking it's C, not C++.
HTH,
- J. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin Maney |
last post by:
Apologies if this isn't news here - I've been too busy this last week
or so for even skimming the traffic here, in part because I've been
messing around with Ubuntu's preview release on a spare machine... and,
of course, spending time on their very busy mailing list. :-) I didn't
find any mention of Ubuntu in a quick scan of recent messages, so...
Ubuntu is a Linux distribution that starts with the breadth of Debian
and adds regular...
|
by: Billy Patton |
last post by:
I have to have my code done for 32 and 64 bit machines on both Linux and
Solaris. Compiling, not a problem.
Testing 32 is not a problem.
But I get segmentation faults when I test on 64 bit machines.
Here's where my problem comes in. I have this macro:
static char thr_buf;
#define THROW(msg) { sprintf(thr_buf,"(%s,%s,%d) :
%s",__FILE__,__FUNCTION__,__LINE__,msg); throw(thr_buf); }
|
by: John Salerno |
last post by:
I'm interested in trying out Linux, probably Ubuntu, but I was wondering
which distribution you guys like to use (because it's a pain trying to
decide!) and you guys are smart.
And to keep it Python related, I'll also ask, is there anything special
I need to know about using Python on Linux? Do any things change, or can
it be used just as I use it on Windows?
Thanks!
|
by: Py PY |
last post by:
(Apologies if this appears twice. I posted it yesterday and it was held
due to a 'suspicious header')
I'm having a hard time trying to get a couple of tests to pass when
compling Python 2.3.5 on Ubuntu Server Edition 6.06 LTS. I'm sure it's
not too far removed from the desktop edition but, clearly, I need to
tweak something or install some missling libs.
uname -a
|
by: Vincent Delporte |
last post by:
Hello
I'm thinking of using Python to build the prototype for a business web
appplication. The development and test machine is XP, while ultimate
deployment will be on a shared Unix web host.
What would you recommend I get, besides the Python engine itself? Good
IDE (Kodomo?) ? Some kind of GUI designer? Add-on's? Other tools?
Thank you.
| |
by: Andrew Wan |
last post by:
I have been developing web applications with ASP & Javascript for a long
time. I have been using Visual Studio 2003.NET. While VS2003 is okay for
intellisense of ASP & Javascript, it's still not that great.
One of the cons of ASP & Javascript is that they're both interpreted, which
means one has twice the amount of work to do interms of syntax checking &
semantic/runtime checking.
Another bad thing is that ASP & Javascript doesn't have...
|
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= |
last post by:
On May 3, 8:09 am, apati...@gmail.com wrote:
A programmer that uses Vista? :O
Vista is a hog of an operating system. Downgrade to Windows XP or get
yourself a Linux distro.
|
by: Jakes |
last post by:
Hey guys. Hope this is the right forum for this kind of question... I'm doing some vacation work and I have been given c++ code that has been written in Microsoft visual studio and I need to evaluate the code and report back on which source files the code isn't compatible with the Linux platform. I want to test each source/header file on it's own for any erroneous code. For example open the ex.cpp and ex.h files and test if the code is Linux...
|
by: defn noob |
last post by:
How hard is it to write a driver for a wireless network card (Ubuntu
doesn't support my card)?
I have a lot of programming experience but in high-level languages
like Python and just minimal C knowledge.
How big is the project, hard to say perhaps but could anyone guess how
many lines approximately?
Is it technically hard or just a lot of specifications to meet?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| | |