<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=C_Basics</id>
	<title>C Basics - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=C_Basics"/>
	<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=C_Basics&amp;action=history"/>
	<updated>2026-05-27T20:40:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.scott5.org/index.php?title=C_Basics&amp;diff=123&amp;oldid=prev</id>
		<title>Scott at 19:13, 31 January 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=C_Basics&amp;diff=123&amp;oldid=prev"/>
		<updated>2011-01-31T19:13:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Reference: http://publications.gbdirect.co.uk/c_book/&lt;br /&gt;
&lt;br /&gt;
==Example Program==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[]){&lt;br /&gt;
    printf(&amp;quot;Enter your name: &amp;quot;);&lt;br /&gt;
    char name[64] = &amp;quot;&amp;quot;;&lt;br /&gt;
    scanf(&amp;quot;%s&amp;quot;, name);&lt;br /&gt;
    printf(&amp;quot;Hi there, %s!\n&amp;quot;, name);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
compile with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ gcc test.c -o test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
# /* hi there&lt;br /&gt;
#  *  here is my multi-line comment&lt;br /&gt;
#  */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Preprocessor directives==&lt;br /&gt;
&lt;br /&gt;
Include another entire file&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Symbol replacement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#define PI 3.1.41592&lt;br /&gt;
circumference = 2*PI*radius;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Function declaration and definition==&lt;br /&gt;
&lt;br /&gt;
If you want a function to be available to other files, declare its prototype in a myprogram.h file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
int make_an_int(int);   /* function prototype&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Define it in the myprogram.c file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
int make_an_int(int my_arg){&lt;br /&gt;
    return my_arg + 10;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A function that takes no argument and returns nothing:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void do_nothing(void);   /* declaration/prototype */&lt;br /&gt;
void do_nothing(void){}  /* definition must have curly braces, no semicolon required*/&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In the body of a function, all variables must be declared before any statements show up.  Variable declarations may include assignment to a literal.&lt;br /&gt;
&lt;br /&gt;
==The main() function==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
int main(){...}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Set the return value to 0 to indicate success; set the return value to something else to specify an error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
&lt;br /&gt;
Multi-line string literals:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;This would not be valid but doesn&amp;#039;t have \&lt;br /&gt;
 a newline in it as far as the compiler is concerned&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
String literals with only white space in between are concatenated:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;All this &amp;quot; &amp;quot;comes out as &amp;quot;&lt;br /&gt;
 &amp;quot;just one string&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scott</name></author>
	</entry>
</feed>