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
|
||||||
|
|
||||||
|
@ -53,9 +56,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
add_executable( huffman src/huffman/src/huffman.c )
|
add_executable( huffman src/huffman/src/huffman.c )
|
||||||
|
|
||||||
execute_process (
|
execute_process (
|
||||||
COMMAND bash -c "mkdir -p src/huffman/testfiles"
|
COMMAND bash -c "mkdir -p src/huffman/testfiles"
|
||||||
COMMAND bash -c "yes 'SAFJALJ AF OIAIFOsdp' | head -c 100KB > src/huffman/testfiles/small.txt"
|
COMMAND bash -c "yes 'SAFJALJ AF OIAIFOsdp' | head -c 100KB > src/huffman/testfiles/small.txt"
|
||||||
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/1K-random.img count=1KiB"
|
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/1K-random.img count=1KiB"
|
||||||
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/10K-random.img count=10KiB"
|
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/10K-random.img count=10KiB"
|
||||||
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/100K-random.img count=100KiB"
|
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/100K-random.img count=100KiB"
|
||||||
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/1M-random.img count=1MiB"
|
COMMAND bash -c "dd if=/dev/urandom of=src/huffman/testfiles/1M-random.img count=1MiB"
|
||||||
|
|
|
@ -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