LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-25-2003, 10:53 PM   #1
gtgoku
Member
 
Registered: Jul 2003
Location: India
Distribution: Slackware 10; FreeBSD 4.10
Posts: 77

Rep: Reputation: 15
Unhappy difference between c++ in windows and linux


I used kate to type in the following code in linux:

#include<iostream.h>
void main()
{
cout<<"hello";
}

and saved it as hello.cpp

and compiled it as

g++ hello.cpp hello.name

and it gave a lot of errors please tell me where have i gone wrong

the same program works when compiled using borland c++ in windows.

Help me please
 
Old 10-26-2003, 01:13 AM   #2
microtim
LQ Newbie
 
Registered: Mar 2003
Location: Cambridge, M
Posts: 16

Rep: Reputation: 0
i changed "void main()" to "int main()" and

% g++ hello.cpp -o hello
compiled. then,

% ./hello
outputs "hello". '-o' specifies the executable output object. i've never programmed on Windows nor do i have any interest.

remember to always include the "errors" in your messages, otherwise other people must explicitly ask.
 
Old 10-26-2003, 07:37 AM   #3
one
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 87

Rep: Reputation: 15
/*you have to use namespace std, is the new standard

try this */:

#include <iostream> // NOT IOSTREAM.H

using namespace std;

int main ()

{

cout << " hello " ;

return 0; // YOU FORGOT THIS

}
 
Old 10-26-2003, 08:39 AM   #4
At0mic_PC
Member
 
Registered: Jul 2003
Location: Mississippi
Distribution: Slack9.1
Posts: 159

Rep: Reputation: 30
Without using namepspace std you would have to:

std::cout << "Like oh my gosh!" << std::endl;

And it should be the same in windows. You may have a sloppy compiler.
 
Old 10-26-2003, 09:23 AM   #5
gtgoku
Member
 
Registered: Jul 2003
Location: India
Distribution: Slackware 10; FreeBSD 4.10
Posts: 77

Original Poster
Rep: Reputation: 15
re:

Thanks all of you
is there any place where i can learn c++ programming in linux,
google did't help me much.
I did't thinks programming c++ in windows and linux would vary soo much.
if just a simple program has so many diff. then surely there should be a lot more changes for more complicated programs.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference b/w linux BIND & windows DNS kami146 Linux - Networking 2 10-16-2009 05:33 AM
encoding speed difference linux and windows shanenin Linux - Software 6 08-09-2004 07:40 AM
A question about the difference between Linux and Windows Kernels ludwig W General 29 04-16-2004 03:44 AM
CD-ROM file format difference between windows and linux kas5058 Linux - Software 1 03-21-2004 04:13 AM
c++ difference between linux and windows lory Programming 5 09-26-2003 08:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration