Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 22nd, 2005, 1:19 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Nice work mate.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 22nd, 2005, 1:36 PM   #12
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Glad that this tutorial has gone to some use an helped someone
Extra bit
While argv[n] can show you an argument, you can also find the filename too, by using argv[0]. This is because the first word you type is counted in the argv array.

I thought my indenting was ok, some things aren't aligned to well as i was having trouble with the second example.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Aug 22nd, 2005, 8:18 PM   #13
Scorpions4ever
Programmer
 
Join Date: Jun 2005
Posts: 86
Rep Power: 4 Scorpions4ever is on a distinguished road
This part contains a lot of extremely BAD advice:
Quote:
Linux(recommended ):
Open the terminal (if you don't know how to do that, then i don't think you should use linux ) cd to the directory with the source code in. For example: cd /home/jack/cpp/myfile.cpp then to use the G++ compiler to compile it type: g++ myfile.cpp this then makes a file called a.out, you can rename it if you like. a.out is an executable, so you can run it by typing ./a.out. If you dont want to put the ./ in front you can put the a.out file into /usr/bin, that way you only have to type the filename to run the program
To make g++ create an executable filename of your choice, you should use the -o option.
g++ -o myfile myfile.cpp
this will create an executable called myfile instead of a.out.

As for executing a file, you can either type
./myfile
or set your PATH variable to include . in its path.
Quote:
export PATH=${PATH}:.
or
setenv PATH ${PATH}:.
depending on your shell.
Then you can type:
myfile
and execute it directly
There is a very good reason that . is not included in the default PATH though and it has to do with security. I'll go into the reasoning later if you want a longer explanation.

Under no condition should you put crap in /usr/bin (or any such system directory, e.g. /sbin, /bin, /usr/sbin etc.) For one, it requires root privileges and secondly, you could overwrite some valuable system utility with your test program.
Scorpions4ever is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC