Main Menu
Home
AVR News
Atmel AVR
AVR Development Tools
Valuable Tools
WinAVR toolset
Makefile for WinAVR
AVR Virtual Simulators
Hardware for prototyping
GCC and AVR-GCC
Short introduction to C
AVR-GCC Tutorial
Example AVR Projects
AVR-GCC articles
WinAVR Site Map
Scienceprog FORUM
ScienceProg BLOG
Disclaimer
WinARM Tutorial
Latest comments
Measuring motor speed and...
Dear Administrator The code above...
More...

Programming AVR ADC module...
hi please send me example usart with...
More...

Measuring motor speed and...
main.c: In function...
More...

Running TX433 and RX433 RF...
(Hopefully this is not a re-post). I am...
More...

Running TX433 and RX433 RF...
I just bnought a pair of the RX/TX 433...
More...

Friendly sites

Related Items:

Recommended sites


The very basics of C PDF Print E-mail
Written by Administrator   
Thursday, 10 August 2006
Last Updated ( Thursday, 10 August 2006 )

C language is function based programming language. C program itself is a function. Usually parameters to C function are passed as arguments. Function consists of a name followed by the parentheses enclosing arguments or an empty pair of parentheses if there are not arguments required. If there are several arguments, they are separated by commas.

The mandatory part in C program is main function. This function must be included in every program because this is a first function which is run after execution of program.

Lets take an example:

/**************** 

#include <stdio.h>

int main(void)

{

printf(“Hello world!\n”);

return 0;

}

/****************

This is a very basic C program, but it contains all necessary elements of it. Lets examine a little bit what we have written here...

#include <stdio.h> - is a preprocessor command. All preprocessor commands are identified by # sign at the beginning of the line. #include command tells preprocessor to open file stdio.h and from it necessary stored parts while compiling program. The file name is surrounded by brackets “<>”. Bracket marks“<>” tels the preprocessor to search for the file in the region defined by operating system variables (for instance “path” variabel in Environment variables). If double quotes are used instead of bracket marks then file searching is done only in default directory of project.

Next line is int main(void). It is always necessary to define the type of function return type and of course function has an arguments. The type int is showing that main function returns an integer and no arguments to the function is needed.

Opening brace “{” indicates the beginning of the block of sentences. On of those sentences is printf(). This function is taken from stdio.h library and writes a message to computer terminal (this case screen).

Return 0 is returning parameter to the function. And every function should end with closing brace “}”.

  “/*” is commenting the line. This means that line marked with “/*”is not included in compilation.


Related Items:

   

Users' Comments  
 

Average user rating

 


Add your comment
Only registered users can comment an article. Please login or register.

No comment posted



mXcomment 1.0.6 © 2007-2008 - visualclinic.fr
License Creative Commons - Some rights reserved
< Prev   Next >

© 2008 WinAVR AVR-GCC Tutorial
Joomla! is Free Software released under the GNU/GPL License.