C: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
Variables in C are ''strictly typed'' meaning they always are one particular kind of representation of information (an integer number, a character, a string of text). | Variables in C are ''strictly typed'' meaning they always are one particular kind of representation of information (an integer number, a character, a string of text). | ||
=== Strings === | |||
Strings in C are ''arrays'' of characters. Abstractly a string in C is simply a pointer; that is, a numeric memory location pointing to the first character of the text in the memory. | |||
<source lang="c"> | |||
char text[] = "pioneering jazz electronic organ recordings"; | |||
int textlen = strlen(text); | |||
for (var i=0; i<textlen; i++) { | |||
printf(""); | |||
} | |||
</source> | |||
== Loops == | == Loops == |
Revision as of 21:09, 18 October 2010
... a programming language to follow B. C is the core language of Unix and later GNU/Linux and the liberation of it's compiler software, gcc (or the Gnu's Not Unix C Compiler), a foundation of the Free Software movement.
Variables
Variables in C are strictly typed meaning they always are one particular kind of representation of information (an integer number, a character, a string of text).
Strings
Strings in C are arrays of characters. Abstractly a string in C is simply a pointer; that is, a numeric memory location pointing to the first character of the text in the memory.
char text[] = "pioneering jazz electronic organ recordings";
int textlen = strlen(text);
for (var i=0; i<textlen; i++) {
printf("");
}
Loops
Like, Bash, C has a for loop:
for (var i=0; i<10; i++) {
printf("Hello %d" % i);
}