Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 01-01-2009, 10:36 PM   #1 (permalink)
Right Off the Assembly Line
 
Manojap's Avatar
 
Join Date: Oct 2004
Location: India,kerala
Posts: 28
Default C++ in knoppix


Give an example of cpp progrm in knoppix, a linux flavor.
Pleas explain..
Compiling
viewing out put
__________________
manojap
Manojap is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-01-2009, 11:31 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: C++ in knoppix

Let's take a sample code:
Code:
#include <iostream> // No .h's for standard libraries anymore

using namespace std;
// All the standard headers use this namespace,
// so lets make it common. 
// Else we type std::cout and std::endl, and so on.
// Just think of it as,
// cout, endl, cin, etc default functions
// belong to this large class
// (actually name-space) called std (standard).

int main () // main must always return int now on ...
{
    cout<<"Hello"<<" "<<"World"<<endl;
    return 0;
}

// Save as file.cpp
Now to compile this:
Code:
# Use g++, the default GNU C++ compiler.
g++ file.cpp -o outfile
# Outfile is the output (binary, executable) file name. By default it is a.out (Assembler.output)
To finally run out compiled binary:
Code:
./outfile # or use: sh outfile
Do all this in the terminal. If any other problem persists, do report here.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 03-01-2009, 12:50 AM   #3 (permalink)
learnhardy
 
Join Date: Oct 2008
Posts: 104
Default Re: C++ in knoppix

Quote:
Originally Posted by QwertyManiac View Post
Let's take a sample code:
Code:
#include <iostream> // No .h's for standard libraries anymore

using namespace std;
// All the standard headers use this namespace,
// so lets make it common. 
// Else we type std::cout and std::endl, and so on.
// Just think of it as,
// cout, endl, cin, etc default functions
// belong to this large class
// (actually name-space) called std (standard).

int main () // main must always return int now on ...
{
    cout<<"Hello"<<" "<<"World"<<endl;
    return 0;
}

// Save as file.cpp
Now to compile this:
Code:
# Use g++, the default GNU C++ compiler.
g++ file.cpp -o outfile
# Outfile is the output (binary, executable) file name. By default it is a.out (Assembler.output)
To finally run out compiled binary:
Code:
./outfile # or use: sh outfile
Do all this in the terminal. If any other problem persists, do report here.
Nice explaination QWERTY ......can u please ......assign me same for the c language.
only conio.h not works in gcc .....?any other differences ....??
__________________
Newbie......
celebrate an ancient art .....
http://ambika.99k.org
ambika is offline  
Old 03-01-2009, 12:52 AM   #4 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: C++ in knoppix

I guess that's about it. The main() must return int, and can't be void.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 03-01-2009, 07:39 AM   #5 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: C++ in knoppix

Quote:
Originally Posted by QwertyManiac View Post
I guess that's about it. The main() must return int, and can't be void.
Thats because ANSI C - 99 standards. Not because of gcc.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Knoppix 3.8.2 vij26 Open Source 4 03-06-2005 10:38 PM
I want a Knoppix CD!!!!!! plsoft Open Source 12 03-06-2005 09:01 PM
knoppix CDs jamesbond007 QnA (read only) 10 28-04-2005 08:49 AM
Knoppix 3.6 neeravkothari QnA (read only) 8 09-09-2004 01:15 PM
Knoppix 3.4 ninad QnA (read only) 1 07-08-2004 07:34 PM

 
Latest Threads
- by gforz
- by soumya
- by Sujeet
- by icebags
- by Charan

Advertisement




All times are GMT +5.5. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2