Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes

 
Lets All Learn C!!!!!!
Reply
Posted 2004-09-16, 12:09 AM
I wrote this for a group of linux wannabe programmers. Ya'll might have use for it too. Since you all look like wannabes.
If it makes no sense, just tell me what you don't get, and I'll try explaining it. Or just PM me or something.

Firstly,

Why learn C?
C allows a great deal of control over the computer system it is running on, as well as being capable of running on any OS, from Windows to Linux, and on nearly any system, PDA to supercomputer.

But what is C?
C is a programming language, much like java or basic. It is basically a set of instructions that the computer has to follow, allowing you to make it perform tasks. C originated several decades ago, and has come to be used by the vast majority of programmers due to its level of control, and it's efficient management of resources.
C is an example of a compiled language, meaning that after your program is written in a simple text editor, it must be turned into an executable file (.sh or .exe) by another program called a C Compiler. You can get a free c compiler from the DJGPP project.

The simplest program.
Open vim or your text editor of choice (Notepad for you Windows buffs). Type in the following:

Code:
#include <stdio.h>

int main()
{
    printf("Hello World!\n");
    return 0;
}
Now to save your file. For a C Compiler to correctly compile a plain text program, it must be in *.c format. For this example we are going to save the file as test.c. Now, after making sure that your extension is correct, let's have a look at the parameters used in the program.

#include <stdio.h>: This is the standard I/O library used in computing. It allows text to be displayed on screen, and receive input from the keyboard. C has quite a few libraries available, making various processes even simpler for you to use in your programs.

int main(): This is a function. main is the name of the function, while int is declaring that a new function is about to start. All C programs must have a function named main, as it's the first function to be run when your program is started.

printf: This command tells the program to write to the standard output, which in this case is the screen. The section in the quotes is the format string, which shows how the data will be formatted when displayed. The \n signifies a carriage return, meaning that the program will start a new line.

return 0: Sends an error code of 0 back to the program. 0 represents no error.

Now to compile our program. Browse to the directory that you saved test.c into using command prompt. To compile, type the following:

Code:
gcc test.c -o test.exe
Now it's just a matter of running your compiled exe!

If all goes well when you run your program it should display the text 'Hello World!' before exiting.

More to come...
In this bloody dawn
I will wash my soul
To call the spirit of vengeance
To deny my wisdom for anger
To break the scream of the silent fool
To be a knightrider of doom

-Knightrider of Doom - Rhapsody
Old
Profile PM WWW Search
Anman is neither ape nor machine; has so far settled for the in-betweenAnman is neither ape nor machine; has so far settled for the in-between
 
 
Anman
 



 
Reply
Posted 2004-09-16, 12:40 AM in reply to Anman's post "Lets All Learn C!!!!!!"
Wrong forum. Moved.
Old
Profile PM WWW Search
Sovereign enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzSovereign enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
Sovereign
 



 
Reply
Posted 2004-09-16, 08:05 AM in reply to Anman's post "Lets All Learn C!!!!!!"
Why not C++? C lets you get away with too much. Default function prototypes? Default variable types? Set a non-const pointer to the value of a pointer to const?
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2004-09-16, 09:01 AM in reply to WetWired's post starting "Why not C++? C lets you get away with..."
We can't have that!

What the fuck did you just say?
Old
Profile PM WWW Search
Sovereign enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzSovereign enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
Sovereign
 



 
Reply
Posted 2004-09-16, 02:29 PM in reply to WetWired's post starting "Why not C++? C lets you get away with..."
Plus MJ already made a C Tutorial thread. He alaborated a lot more me thinks.


~ KAMAHAME---Oh shit it's happening again.... ~
Old
Profile PM WWW Search
Tyrannicide enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzTyrannicide enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
Tyrannicide
 



 
Reply
Posted 2004-09-16, 02:40 PM in reply to Tyrannicide's post starting "Plus MJ already made a C Tutorial..."
Tyrannicide said:
Plus MJ already made a C Tutorial thread. He alaborated a lot more me thinks.
Once I have a bit of time I need to finish that up.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 



 
Reply
Posted 2004-09-16, 03:28 PM in reply to Anman's post "Lets All Learn C!!!!!!"
#include <stdio.h>

class Anman {

public:
Anman() { ShutsUp(true); };
~Anman() {};
void WhatIsAnmanDoing();

private:
boolean ShutsUp;

};

void Anman::WhatIsAnmanDoing(){
if(ShutsUp) printf("He finally shut up!\n");
}

int main(){
Amnan idiot;
idiot.WhatIsAnmanDoing();
return 0;
}
Old
Profile PM WWW Search
Mantralord seldom sees opportunities until they cease to beMantralord seldom sees opportunities until they cease to beMantralord seldom sees opportunities until they cease to beMantralord seldom sees opportunities until they cease to be
 
 
Mantralord
 



 
Reply
Posted 2004-09-17, 07:31 AM in reply to Mantralord's post starting "#include <stdio.h> class Anman { ..."
DAMIT! THIS WAS SUPPOSE TO SPAM !!!! I HATE YOU ALL!!! *runs knife through each rib rivet*
In this bloody dawn
I will wash my soul
To call the spirit of vengeance
To deny my wisdom for anger
To break the scream of the silent fool
To be a knightrider of doom

-Knightrider of Doom - Rhapsody
Old
Profile PM WWW Search
Anman is neither ape nor machine; has so far settled for the in-betweenAnman is neither ape nor machine; has so far settled for the in-between
 
 
Anman
 



 
Reply
Posted 2004-09-17, 11:16 PM in reply to Anman's post "Lets All Learn C!!!!!!"
Anman, what distro are you running?
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 



 
Reply
Posted 2004-09-17, 11:32 PM in reply to Anman's post "Lets All Learn C!!!!!!"
Anman said:

#include <stdio.h>: This is the standard I/O library used in computing. It allows text to be displayed on screen, and receive input from the keyboard. C has quite a few libraries available, making various processes even simpler for you to use in your programs.
Probably be a good idea to define what a library is.

Quote:
int main(): while int is declaring that a new function is about to start.
??

Quote:
All C programs must have a function named main, as it's the first function to be run when your program is started.
Not necessarily.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum 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


All times are GMT -6. The time now is 10:22 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.