View Full Version : C&C++ Language
mrdosa
March 26th, 2008, 08:14 PM
I have both g++ and gcc, this I know from my synaptic package manager, it shows both are installed. I want to know, how can I open these. I mean, how should I go about using C and C++
I am a novice to all this, so can anyone help me out? Please!
Thanks in Advance.
LaRoza
March 26th, 2008, 08:15 PM
See the sticky in the Programming Talk.
(Thread moved)
scragar
March 26th, 2008, 08:17 PM
gcc FILENAME or PATH
to compile a .c file:
gcc FILENAME -o PLACE TO STORE COMPILED VERSION
to compile it with a name other than it's default file(I think it's either called out or a.out or something like that.
mrdosa
March 26th, 2008, 08:22 PM
So, if I just want to write a small program, how should I go about?
LaRoza
March 26th, 2008, 08:26 PM
So, if I just want to write a small program, how should I go about?
See the sticky, which has examples and a lot of information.
scragar
March 26th, 2008, 08:27 PM
if your just learning then I have a few tips:
1: install binfmtc so you can run your C/C++ files without needing to compile your programs before testingsudo apt-get install binfmtcthen start all your files with the comment:/*BINFMTCXX:
*/
2: get used to saving files as .c and giving them execute privilages so you can launch them with binfmtc.
3: find a good tutorial.
iansane
March 26th, 2008, 08:29 PM
You don't actually open them. You use the right commands in terminal to compile a program like helloworld.cpp. or you install an IDE (integrated development enviroment) that uses them as a backend.
you can go here.
http://www.cplusplus.com/doc/tutorial/program_structure.html
put the helloworld code in a file and save it as helloWorld.cpp.
Then in terminal cd to the dir. where it is and type
g++ -O helloWorld.cpp -o helloWorld
This compiles it into an executable which can be run from terminal with
./helloWorld
If everything works you should see "hello World" in terminal
That is the most basic way to use g++
mrdosa
March 26th, 2008, 08:30 PM
Thanks. I will do what you have suggested.
iansane
March 26th, 2008, 08:32 PM
I never noticed you guys have this programming forum here. Too bad I can't get someone to do my homework according to the sticky. LOL just kidding.
LaRoza
March 26th, 2008, 08:34 PM
I never noticed you guys have this c++ forum here. Too bad I can't get someone to do my homework according to the sticky. LOL just kidding.
Well, I am thinking of trying to get a change in the policy, to allow us to help, but on the condition we give the wrong answers.
mrdosa
March 26th, 2008, 08:40 PM
I did what insane told. It worked, but isnt it a bit difficult to keep checking whether the program works? I mean, do we have to compile from terminal each time and run the compile file? is there nothng like Turbo C out here!?
mrdosa
March 26th, 2008, 08:44 PM
Scrager I have installed the program u asked me to, now, should I use the text editor to write the c program and execute it?
LaRoza
March 26th, 2008, 08:44 PM
I did what insane told. It worked, but isnt it a bit difficult to keep checking whether the program works? I mean, do we have to compile from terminal each time and run the compile file? is there nothng like Turbo C out here!?
You can use an IDE, and compile and run in one click.
(I don't use IDE's, and have quick compile scripts and aliases, but I have briefly used Geany, and it was nice and light, but usable)
mrdosa
March 26th, 2008, 08:51 PM
Thanks guys!! I used to use turbo c on windows way back in first year of college. And jsut started using linux. I am just starting to learn C and C++ again and wrote my first program now!!:guitar: Now, if someone can post a good sticky here on how to use ubuntu for all C and C++ programming, it would be great.
Psst. I dont know what an IDE is! I am way to ignorant I guess. If I could get hold of any tutorial on how to use ubuntu for programming c, i will stop asking!!:)
bruce89
March 26th, 2008, 08:53 PM
Thanks guys!! I used to use turbo c on windows way back in first year of college.
[...]
Psst. I dont know what an IDE is!
See your own words. (Integrated Development Environment)
mrdosa
March 26th, 2008, 08:59 PM
Oops sorry!! Told you...am way to ignorant. I will try and learn this time around. Thanks once again. Just starting afresh as a hobby. I am a mechanical engineer BTW!!:lolflag:
LaRoza
March 26th, 2008, 09:04 PM
Now, if someone can post a good sticky here on how to use ubuntu for all C and C++ programming, it would be great.
The sticky in this forum has two links for C and C++ programming.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.