diff --git a/.gitignore b/.gitignore index 78634e5..efa0f62 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ bin */bin obj */obj +CMakeFiles +build +CMakeCache.txt +Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0d64c00 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.0) + +project(base) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +include_directories(${PROJECT_SOURCE_DIR}) +add_executable( abc src/abc.c ) +add_executable( adder src/adder.c ) +add_executable( args src/args.c ) +add_executable( arrToBin src/arrToBin.c ) +add_executable( ascii src/ascii.c ) +add_executable( calculator src/calculator.c ) +add_executable( callreference src/callreference.c ) +add_executable( complex src/complex.c ) +add_executable( dividableBy7 src/dividableBy7.c ) +add_executable( structdump src/structdump.c ) +add_executable( echo src/echo.c ) +add_executable( echochar src/echochar.c ) +add_executable( euler src/euler.c ) +add_executable( factorial src/factorial.c ) +add_executable( fail src/fail.c ) +add_executable( fread src/fread.c ) +add_executable( hello-world src/hello-world.c ) +add_executable( options src/options.c ) +add_executable( pointermagic src/pointermagic.c ) +add_executable( primenumbers src/primenumbers.c ) +add_executable( quersumme src/quersumme.c ) +add_executable( readfile src/readfile.c ) +add_executable( redefinition src/redefinition.c ) +add_executable( redefinition-if src/redefinition-if.c ) +add_executable( return-specified src/return-specified.c ) +add_executable( scanf-test src/scanf-test.c ) +add_executable( scnaf-hex-test src/scnaf-hex-test.c ) +add_executable( signed-to-unsigned src/signed-to-unsigned.c ) +add_executable( sizeofs src/sizeofs.c ) +add_executable( success src/success.c ) +add_executable( sum src/sum.c ) +add_executable( tabtest src/tabtest.c ) +add_executable( umlaut src/umlaut.c ) +add_executable( unary-double-not src/unary-double-not.c ) +add_executable( warning src/warning.c ) +add_executable( pointer-arithmetic src/pointer-arithmetic.c ) + +target_link_libraries(abc m) # link libm to abc diff --git a/abc.c b/abc.c deleted file mode 100644 index 21e5506..0000000 --- a/abc.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char **argv){ - - if(argc<3){ - printf("not enough args! Ex: ./abc 12 -3 5\n"); - exit(EXIT_FAILURE); - } - double a = atoi(argv[1]); - double b = atoi(argv[2]); - double c = atoi(argv[3]); - - printf("(%f)x²+(%f)x+(%f)=0\n", a, b, c); - double l1 = 0, l2 = 0; - double cl1 = 0, cl2 = 0; - l1=(-b + sqrt((b*b)-(4*a*c)))/(2*a); - l2=(-b - sqrt((b*b)-(4*a*c)))/(2*a); - cl1=(-b + csqrt((b*b)-(4*a*c)))/(2*a); - cl2=(-b - csqrt((b*b)-(4*a*c)))/(2*a); - printf("(-%.0f (+-) sqrt[(%.0f²)-(4*%.0f*%.0f)])/2*%.0f\n", b, b, a, c, a); - printf("x1=%f x2=%f\n", l1, l2); - printf("(complex mode)\nx1=%fi\tx2=%fi\n", cl1, cl2); - return 0; -} diff --git a/adder.c b/adder.c deleted file mode 100644 index f0d22b1..0000000 --- a/adder.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main() { - int a, b; - printf("Please input two integers to be added.\n"); - scanf("%d %d", &a, &b); - printf("%d + %d = %d\n", a, b, a+b); - return 0; -} diff --git a/args.c b/args.c deleted file mode 100644 index 853554c..0000000 --- a/args.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int main(int argc, char* argv[]){ - - if(argc==1){ - printf("Recieved only one argument, idiot"); - return 1; - } - - for(int i = 0; i < argc+1; i++){ - printf("%d. [%s]\n", i+1, argv[i]); - } - - return 0; -} diff --git a/arrToBin.c b/arrToBin.c deleted file mode 100644 index 8fa42bd..0000000 --- a/arrToBin.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -int main(){ - // input as single int, output as array of ints with only 0 and 1s - - char str_i[20]; - int i; - - fgets(str_i, 20, stdin); - i = strtol(str_i, NULL, 0); - printf("%d", i); - - int bin[16] = { -1 }; - int b; - - printf("[CONTROL]as hex %x\n", i); - for(int j = 16; j>0; j--){ - b = i%2; - i /= 2; - bin[i] = b; - } - for(int j = 0; j < 16; j++){ - printf("%d", bin[j]); - } - printf("\n"); - return 0; -} diff --git a/ascii.c b/ascii.c deleted file mode 100644 index d0605ef..0000000 --- a/ascii.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main(){ - for(int i=0; i<256; i++){ - printf("(dec)%d\t(hex)0x%02x\t(char)%c\t\n",i,i,i); - } - return 0; -} diff --git a/calculator.c b/calculator.c deleted file mode 100644 index 535710b..0000000 --- a/calculator.c +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include - -double factorial(double i) { - if(i <= 1) { - return 1; - } - return i * factorial(i - 1); -} - -double power(double a, double b) { - double result = a; - for(int i=0;i - -int* ref(int *i, int* j, int* result){ - *result = *i + *j; - return result; -} - -int val(int a, int b){ - return a+b; -} - -int main(){ - - int x = 1000; - int y = 337; - int z; - printf("given: %d\n", x); - printf("reference: %d\n", *ref(&x, &y, &z)); - printf("value: %d\n", val(x, y)); - - return 0; -} diff --git a/cmake_install.cmake b/cmake_install.cmake new file mode 100644 index 0000000..934c11e --- /dev/null +++ b/cmake_install.cmake @@ -0,0 +1,54 @@ +# Install script for directory: /home/plex/Documents/code/c/c-basic + +# Set the install prefix +if(NOT DEFINED CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "/usr/local") +endif() +string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + if(BUILD_TYPE) + string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + else() + set(CMAKE_INSTALL_CONFIG_NAME "") + endif() + message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +endif() + +# Set the component getting installed. +if(NOT CMAKE_INSTALL_COMPONENT) + if(COMPONENT) + message(STATUS "Install component: \"${COMPONENT}\"") + set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + else() + set(CMAKE_INSTALL_COMPONENT) + endif() +endif() + +# Install shared libraries without execute permission? +if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + set(CMAKE_INSTALL_SO_NO_EXE "0") +endif() + +# Is this installation the result of a crosscompile? +if(NOT DEFINED CMAKE_CROSSCOMPILING) + set(CMAKE_CROSSCOMPILING "FALSE") +endif() + +# Set default install directory permissions. +if(NOT DEFINED CMAKE_OBJDUMP) + set(CMAKE_OBJDUMP "/usr/bin/objdump") +endif() + +if(CMAKE_INSTALL_COMPONENT) + set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") +else() + set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") +endif() + +string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT + "${CMAKE_INSTALL_MANIFEST_FILES}") +file(WRITE "/home/plex/Documents/code/c/c-basic/${CMAKE_INSTALL_MANIFEST}" + "${CMAKE_INSTALL_MANIFEST_CONTENT}") diff --git a/compile-all.sh b/compile-all.sh deleted file mode 100755 index 35b65a2..0000000 --- a/compile-all.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -mkdir -p bin -returnCode=0 -echo -e "compiling all files in working directory $(pwd)\n" -for file in $(/bin/ls *.c); -do - echo "compiling $file ..." - noext=$(echo "$file" | cut -f 1 -d '.') - gcc $file -o bin/$noext -lm - if [ "$?" -ne 0 ] - then - echo -e "\nERROR: could not compile $file !\n"; - returnCode=1; - fi -done -echo -ne "\nfinished compiling all source files. "; -if [ "$returnCode" -eq 0 ] -then - echo -ne "No errors occured."; -else - echo -ne "Some errors occured."; -fi -echo ""; -exit $returnCode diff --git a/compile-and-run.sh b/compile-and-run.sh deleted file mode 100755 index d7bd02a..0000000 --- a/compile-and-run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -mkdir -p bin -noext=$(echo "$1" | cut -f 1 -d '.') -echo "compiling $1 ..." -gcc $1 -o bin/$noext -lm -./bin/$noext $2 $3 $4 $5 $6 $7 $8 $9 diff --git a/compile.sh b/compile.sh deleted file mode 100755 index 0405b59..0000000 --- a/compile.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -mkdir -p bin -echo "compiling $1 ..." -noext=$(echo "$1" | cut -f 1 -d '.') -gcc $1 -o bin/$noext -lm diff --git a/complex.c b/complex.c deleted file mode 100644 index dcd2a52..0000000 --- a/complex.c +++ /dev/null @@ -1,83 +0,0 @@ -#include - -typedef struct -{ - float real; - float imaginary; -}complex; - -complex assignComplex(){ - float r, i; - scanf("%f", &r); - scanf("%f", &i); - complex c; - c.real = r; - c.imaginary = i; - return c; -} - -void addComplex() { - printf("First complex\n"); - complex a = assignComplex(); - printf("Second complex\n"); - complex b = assignComplex(); - - complex r; - r.real = a.real + b.real; - r.imaginary = a.imaginary + b.imaginary; - printf("Result: %f+%fi\n", r.real, r.imaginary); -} - -void subComplex() { - printf("First complex\n"); - complex a = assignComplex(); - printf("Second complex\n"); - complex b = assignComplex(); - - complex r; - r.real = a.real - b.real; - r.imaginary = a.imaginary - b.imaginary; - printf("Result: %f+%fi\n", r.real, r.imaginary); -} - -void mulComplex() { - printf("First complex\n"); - complex a = assignComplex(); - printf("Second complex\n"); - complex b = assignComplex(); - - complex r; - r.real = a.real * b.real; - r.imaginary = a.imaginary * b.imaginary; - printf("Result: %f+%fi\n", r.real, r.imaginary); -} - -void divComplex() { - printf("First complex\n"); - complex a = assignComplex(); - printf("Second complex\n"); - complex b = assignComplex(); - - complex r; - r.real = a.real / b.real; - r.imaginary = a.imaginary / b.imaginary; - printf("Result: %f+%fi\n", r.real, r.imaginary); -} - -int main() { - printf("Usage:\n\toperations: + - * /\n\tquit: q\n"); - - char in; - while(1){ - - in = getchar(); - switch(in){ - case 'q': return 0; - case '+': addComplex(); break; - case '-': subComplex(); break; - case '*': mulComplex(); break; - case '/': divComplex(); break; - default: printf("kaputt\n"); break; - } - } -} diff --git a/dividableBy7.c b/dividableBy7.c deleted file mode 100644 index bca2ea4..0000000 --- a/dividableBy7.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * lower and upper end as user input - * use a for loop to output all numbers for which 7|x is true. - */ - -#include - -int main() { - - int a,b; - printf("input lower end:\n"); - fflush(stdin); - scanf("%d",&a); - printf("input upper end:\n"); - fflush(stdin); - scanf("%d",&b); - - printf("inputs: %d %d\n", a, b); - for(int i=a; i<=b; i++){ - if(i%7==0) - printf("%d ", i); - if(i==b) - printf("\n"); - } - - return 0; -} diff --git a/dump.c b/dump.c deleted file mode 100644 index d8cea6b..0000000 --- a/dump.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -struct a { - int a; - char str[30]; -}; - -/* - * give an argument to keep the file /tmp/structdump - * like this: bin/dump aaa - */ - -int main(int argc, char** argv){ - struct a* mystruct = malloc(sizeof(struct a)); - if(mystruct == NULL){ - printf("malloc for 1st struct failed!\n"); - return 1; - } - mystruct->a = 12; - char s[30] = "Wer das liest ist doof"; - strcpy(mystruct->str, s); - FILE* fptr = fopen("/tmp/structdump", "wb"); - fwrite(mystruct, sizeof(struct a), 1, fptr); - fclose(fptr); - free(mystruct); - - fptr = fopen("/tmp/structdump", "rb"); - mystruct = malloc(sizeof(struct a)); - if(mystruct == NULL){ - printf("malloc for 2nd struct failed!\n"); - return 1; - } - fread(mystruct, sizeof(struct a), 1, fptr); - printf("mystruct->a: %d\nmystruct->str: \"%s\"\n", mystruct->a, mystruct->str); // SIGSEV - free(mystruct); - fclose(fptr); - if(argc<2) - remove("/tmp/structdump"); - return 0; -} diff --git a/echo.c b/echo.c deleted file mode 100644 index 8a35260..0000000 --- a/echo.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() { - char s[100]; - //gets(s); - /* - * Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and be‐ - * cause gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break - * computer security. Use fgets() instead. - * - * For more information, see CWE-242 (aka "Use of Inherently Dangerous Function") at http://cwe.mitre.org/data/definitions/242.html - * - */ - fgets(s, sizeof(s), stdin); - printf("%s\n", s); - return 0; -} diff --git a/echochar.c b/echochar.c deleted file mode 100644 index a2020a9..0000000 --- a/echochar.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main() { - - char a = getchar(); - printf("%c", a); - return 0; -} diff --git a/euler.c b/euler.c deleted file mode 100644 index 30272da..0000000 --- a/euler.c +++ /dev/null @@ -1,50 +0,0 @@ -#include - -#include -#include - -// range of unsigned long long is: -// 18.446.744.073.709.551.615 -// maximum factorial with this is 65! -// Double goes up to 170! -double factorial(double i) { - - if(i <= 1) { - return 1; - } - return i * factorial(i - 1); -} - - double factorialFor(double given){ - double p = 1; - - // someone said i need 2 for loops. Totally wrong? - for(int j=1;j -#include - -// range of unsigned long long is: -// 18.446.744.073.709.551.615 -// maximum factorial with this is 65! -// Double goes up to 170! -double factorial(double i) { - - if(i <= 1) { - return 1; - } - return i * factorial(i - 1); -} - - double factorialFor(double given){ - double p = 1; - - // someone said i need 2 for loops. Totally wrong? - for(int j=1;j - -/* - * This program has the purpose of returning a -1 value, indicating the shell that something has gone wrong - * while the program was running. - */ - -int main(){ - return -1; -} diff --git a/fread.c b/fread.c deleted file mode 100644 index 15989c7..0000000 --- a/fread.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -int main () { - FILE *fp; - char c[] = "this is tutorialspoint"; - char buffer[100]; - - /* Open file for both reading and writing */ - fp = fopen("file.txt", "w+"); - - /* Write data to the file */ - fwrite(c, strlen(c) + 1, 1, fp); - - /* Seek to the beginning of the file */ - fseek(fp, 0, SEEK_SET); - - /* Read and display data */ - fread(buffer, strlen(c)+1, 1, fp); - printf("%s\n", buffer); - fclose(fp); - - return(0); -} diff --git a/hello-world.c b/hello-world.c deleted file mode 100644 index 04ce434..0000000 --- a/hello-world.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main() { - printf("Hello world!\n"); - return 0; -} diff --git a/options.c b/options.c deleted file mode 100644 index 821e50a..0000000 --- a/options.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - bool isCaseInsensitive = false; - int opt; - enum { CHARACTER_MODE, WORD_MODE, LINE_MODE } mode = CHARACTER_MODE; - - while ((opt = getopt(argc, argv, "ilw")) != -1) { - switch (opt) { - case 'i': isCaseInsensitive = true; break; - case 'l': mode = LINE_MODE; break; - case 'w': mode = WORD_MODE; break; - default: - fprintf(stderr, "Usage: %s [-ilw] [file...]\n", argv[0]); - exit(EXIT_FAILURE); - } - } - - // Now optind (declared extern int by ) is the index of the first non-option argument. - // If it is >= argc, there were no non-option arguments. - -} diff --git a/pointer-arithmetic.c b/pointer-arithmetic.c deleted file mode 100644 index 1c00204..0000000 --- a/pointer-arithmetic.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main() { - int a[5] = {22, 33, 44, 55, 66}; - int *ptr = NULL; - ptr = a; /* point to the first array element */ - for(int i = 0; i < 50; i++) { - printf(" value:0x%-10x\tor 0d%-16d\tAdress:%-8x\n", *(ptr+i), *(ptr+i), ptr+i); /* 33 */ -}} diff --git a/pointermagic.c b/pointermagic.c deleted file mode 100644 index 0e9d93e..0000000 --- a/pointermagic.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -void printLoc(int y) { - printf("Address of y is %x\n", &y); -} - -void printPointerLoc(int *x) { - printf("Adress of x is %x\n", &x); - printf("Adress the x pointer points to is %x\n", x); - printf("Adress of whatever *x is is %x\n", *x); -} - -int main() { - int a = 0xAAAA; - printf("Address of a is %x\n", &a); - printLoc(a); - printPointerLoc(&a); - return 0; -} diff --git a/primenumbers.c b/primenumbers.c deleted file mode 100644 index 2fd7994..0000000 --- a/primenumbers.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -int main(int argc, char** argv) { - int maxPrime = atoi(argv[1]); - - int *arr1 = malloc(sizeof(int)*maxPrime); - if(arr1==NULL) - return -1; - for(int i=0; i0)&&(arr1[j]!=p)) - arr1[j]=-1; - } - // get next prime in arr - // FIXME - p = arr1[i]; - for(int l=0;l<512;l++){ - if(p>0) - break; - else { - p = arr1[i+l]; - } - } - for(int l=0;l0) - printf("%d ", arr1[i]); - } - free(arr1); - printf("\n"); - return 0; -} diff --git a/quersumme.c b/quersumme.c deleted file mode 100644 index 7484927..0000000 --- a/quersumme.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -int main() { - int a, digits = 0, b = 0; - printf("input a number for calculation\n"); - fflush(stdin); - scanf("%d",&a); - - int digit[128]; - - // look out for wrong order - for(int i=0; i<128; i++) { - digit[i] = a % 10; - if(a>0) - a = a / 10; - else { - if(digits==-1) - digits = i; - digit[i] = -1; - } - //printf("%d. digit is: %d\n", i, digit[i]); - } - - // array is in wrong order, but who cares for the quersumme - for(int i=0; i<128; i++){ - if(digit[i]>0) - b += digit[i]; - } - printf("quersumme is: %d\n", b); - return 0; -} diff --git a/readfile.c b/readfile.c deleted file mode 100644 index fb5f773..0000000 --- a/readfile.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -int main(void) -{ - char filename[] = "file.txt"; - char buf[2]; - FILE *fp; - - if ((fp = fopen(filename, "rb")) == NULL) - { - printf("Unable to open file: %s\n", filename); - return EXIT_FAILURE; - } - - if (fread(buf, 1, 2, fp) == 2) - { - printf("%02x %02x\n", (int) buf[0], (int) buf[1]); - } - - fclose(fp); - return 0; -} diff --git a/redefinition-if.c b/redefinition-if.c deleted file mode 100644 index 8c03c48..0000000 --- a/redefinition-if.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -int main() { - int a; - if(1){ - int a; // works, this a is only in scope of the if statement. - } - return 0; -} diff --git a/redefinition.c b/redefinition.c deleted file mode 100644 index 081dcea..0000000 --- a/redefinition.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -int a = 1; -int main() { - int a = 2; - printf("%d\n", a); // local overrides global - return 0; -} diff --git a/return-specified.c b/return-specified.c deleted file mode 100644 index 7477ffa..0000000 --- a/return-specified.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -/* - * This program takes the given argument and returns it as an integer. - * It might be useful to test a shell. - */ - -int main(int argc, char** argv){ - if(argc<2){ - printf("No argument given.\n"); - return -1; - } - return atoi(argv[1]); -} diff --git a/scanf-test.c b/scanf-test.c deleted file mode 100644 index 8a489b8..0000000 --- a/scanf-test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main() { - int a; - float f; - char s[20]; - printf("input an integer, a float, then a string.\n"); - scanf("%d %f %s", &a, &f, s); - printf("%d %f %s\n", a, f, s); - return 0; -} diff --git a/scnaf-hex-test.c b/scnaf-hex-test.c deleted file mode 100644 index b9b7fa2..0000000 --- a/scnaf-hex-test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main() { - int a; - scanf("%x", &a); - printf("hex: %x dec: %d\n", a, a); - return 0; - } diff --git a/signed-to-unsigned.c b/signed-to-unsigned.c deleted file mode 100644 index 9f461a7..0000000 --- a/signed-to-unsigned.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main() { - signed int a = -1; - printf("%u\n",a); // no need to type cast. %u interprets given bytes of type unsigned int regardless of the datatype. truly low level - } diff --git a/sizeofs.c b/sizeofs.c deleted file mode 100644 index 4a33c01..0000000 --- a/sizeofs.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int main() { - printf("int: %ld \n", sizeof(int)); - printf("float: %ld \n", sizeof(float)); - printf("double: %ld \n", sizeof(double)); - printf("char: %ld \n", sizeof(char)); - - return 0; -} diff --git a/success.c b/success.c deleted file mode 100644 index 4278030..0000000 --- a/success.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -/* - * This program has the purpose of returning a 0 value, indicating to the shell that the program was - * executed successfully. - */ - -int main(){ - return 0; -} diff --git a/sum.c b/sum.c deleted file mode 100644 index 75126f5..0000000 --- a/sum.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main(){ - - int result = 0; - for (int i = 1; i < 101; i++){ - result+=i; - } - printf("sum of 1 up to 100 is: %d\n", result); - return 0; -} diff --git a/tabtest.c b/tabtest.c deleted file mode 100644 index 7902237..0000000 --- a/tabtest.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main() { - printf("horizontal\ttab\n"); - printf("vertical%ctab\n", 11); - printf("reference line\n"); - return 0; -} diff --git a/umlaut.c b/umlaut.c deleted file mode 100644 index bbdb9d3..0000000 --- a/umlaut.c +++ /dev/null @@ -1,3 +0,0 @@ -#include -int main() { return 0; } -int zähler() { return 0; } // umlaute is an unknown char for gcc diff --git a/unary-double-not.c b/unary-double-not.c deleted file mode 100644 index a611f37..0000000 --- a/unary-double-not.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(){ - printf("%d\n",!!42); - return 0; -} diff --git a/warning.c b/warning.c deleted file mode 100644 index 06373c6..0000000 --- a/warning.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int main(){ - char s[2]; - /* - * The following line of code is unsafe. It writes up to 10 bytes into the char array 's', which is only - * 2 Bytes big. A Buffer Overflow can happen. I have chosen to keep that line, because i wanted a source - * file that produces a compiler warning when it is compiled. That is the true purpose of this file. - * - * a safe alternative would be: fgets(s, 2, stdin); - */ - fgets(s, 10, stdin); // UNSAFE - printf("%s\n",s); - return 0; -}