more basics + build stuff
This commit is contained in:
parent
367f5a3aab
commit
f0ffe26987
|
@ -42,7 +42,10 @@ add_executable( tabtest src/tabtest.c )
|
||||||
add_executable( umlaut src/umlaut.c )
|
add_executable( umlaut src/umlaut.c )
|
||||||
add_executable( unary-double-not src/unary-double-not.c )
|
add_executable( unary-double-not src/unary-double-not.c )
|
||||||
add_executable( warning src/warning.c )
|
add_executable( warning src/warning.c )
|
||||||
|
add_executable( miniio src/miniio.c )
|
||||||
|
add_executable( stackoverflow src/stackoverflow.c )
|
||||||
add_executable( pointer-arithmetic src/pointer-arithmetic.c )
|
add_executable( pointer-arithmetic src/pointer-arithmetic.c )
|
||||||
|
add_executable( while-to-do-while src/while-to-do-while.c )
|
||||||
|
|
||||||
target_link_libraries(abc m) # link libm to abc
|
target_link_libraries(abc m) # link libm to abc
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int my_strlen(const char *s) {
|
||||||
|
int len = 0;
|
||||||
|
while (s[len] != 0) {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char word[] = "hallo\0"; // not NULL terminated
|
||||||
|
|
||||||
|
printf("word is %d long\n", my_strlen(word));
|
||||||
|
printf("word is actually %lu long\n", strlen(word));
|
||||||
|
printf("success: %b", my_strlen(word) == strlen(word));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
int mem = 0x1337;
|
||||||
|
|
||||||
|
void foo() {
|
||||||
|
int buf = 0;
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
foo();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int init = 5;
|
||||||
|
int i = init;
|
||||||
|
while (i < 10 || i == init) {
|
||||||
|
printf("helo %d\n", i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = init;
|
||||||
|
do {
|
||||||
|
printf("ahelo %d\n", i);
|
||||||
|
i++;
|
||||||
|
} while (i < 10);
|
||||||
|
}
|
Loading…
Reference in New Issue