LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2004, 05:04 PM   #1
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Rep: Reputation: 30
hello world in g++


hi

i am using g++ to compile my stuff and i get an error when i try to comile my hello world

here is the code:

#include<iostream.h>
main()
{
cout << "Hello World";
cin.ignore();
return 0;
}

then i did :

bash-2.05b$ g++ -o bla test1.cpp

then i get the error:


from test1.cpp:1:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

hrm what am i doing wrong?

thanks guys
 
Old 02-21-2004, 05:08 PM   #2
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
oh woops forgot the int before main heh heh

lets see if that works.....
 
Old 02-21-2004, 05:10 PM   #3
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
hrmm i still get the same error

any suggestions?
thanks
 
Old 02-21-2004, 05:32 PM   #4
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Code:
#include<iostream>

int main()
{
	std::cout << "Hello World";
	std::cin.ignore();
	return 0;
}
Lyle
 
Old 02-21-2004, 06:20 PM   #5
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
this works too.

#include<stdio.h>

int main(int argv, char argc)
{
printf("Hello World");
return 0;
}
 
Old 02-21-2004, 07:27 PM   #6
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
That's a C program.

Lyle
 
Old 02-21-2004, 07:28 PM   #7
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
oh yay!!

i figured it out baby!

#include <iostream>
#include <string>
using namespace std;
 
Old 02-21-2004, 07:29 PM   #8
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
i guess g++ doesnt like the old header formats....
 
Old 02-21-2004, 07:45 PM   #9
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
Lyle, it compiles in g++ good enough.
 
Old 02-21-2004, 07:53 PM   #10
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Quote:
Originally posted by chewysplace
Lyle, it compiles in g++ good enough.
True, but I'm working under the assumption that Longinus was trying to write a C++ program since the iostream header was used.

Lyle
 
Old 02-21-2004, 07:58 PM   #11
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
aaaaaahhh ok.
never realy liked iostream.h
dont know why.
 
Old 02-21-2004, 08:10 PM   #12
Chris Weimer
Member
 
Registered: Jan 2004
Location: NYC
Distribution: Fedora XFCE
Posts: 91

Rep: Reputation: Disabled
is there an <iostream.h> for C? I don't think so. I thought it came along riding the C++ classes/templates wave. I prefer print() in theory, but in practicality, I use fstream and iostream a whole bunch. Maybe that's just because I learnt C++ first.
 
Old 02-21-2004, 09:19 PM   #13
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
i learned c++ first but used print instead.
 
Old 02-21-2004, 09:28 PM   #14
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
oh so you can use the print() funcion in c++?!?
 
Old 02-21-2004, 10:24 PM   #15
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
Code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
     printf("hello world");
     return 0;
}
worked for me , try it.....
 
  


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
Hello World! StephenCM LinuxQuestions.org Member Intro 9 01-14-2005 12:59 PM
A whole new world 8oluf7 LinuxQuestions.org Member Intro 2 01-08-2005 06:36 AM
Hello World! professor_x_00 LinuxQuestions.org Member Intro 5 03-24-2004 05:51 AM
world writeable files will not stay world writeable antken Mandriva 1 03-02-2004 05:04 PM
Hello World! flaw Linux - Newbie 6 09-19-2002 02:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 PM.

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