commit c09145a0f546912d6e504afc6a0775afc675d34f Author: pro100ton Date: Wed Dec 4 23:31:26 2024 +0300 Back to C learning diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc96050 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# ---> C +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +.DS_Store + +.vscode* +./build/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..23c457c --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# c_programming_language + diff --git a/book/The.C.Programming.Language.2Nd.Ed Prentice.Hall.Brian.W.Kernighan.and.Dennis.M.Ritchie..pdf b/book/The.C.Programming.Language.2Nd.Ed Prentice.Hall.Brian.W.Kernighan.and.Dennis.M.Ritchie..pdf new file mode 100644 index 0000000..cc17079 Binary files /dev/null and b/book/The.C.Programming.Language.2Nd.Ed Prentice.Hall.Brian.W.Kernighan.and.Dennis.M.Ritchie..pdf differ diff --git a/build/celcius b/build/celcius new file mode 100755 index 0000000..08cd2e6 Binary files /dev/null and b/build/celcius differ diff --git a/c_modern_approach/Fundamentials/2_001_section b/c_modern_approach/Fundamentials/2_001_section new file mode 100755 index 0000000..6f61ff1 Binary files /dev/null and b/c_modern_approach/Fundamentials/2_001_section differ diff --git a/c_modern_approach/Fundamentials/2_001_section.c b/c_modern_approach/Fundamentials/2_001_section.c new file mode 100644 index 0000000..50c6781 --- /dev/null +++ b/c_modern_approach/Fundamentials/2_001_section.c @@ -0,0 +1,7 @@ +#include +int main(void) { + printf("Privet Sashka kak dela"); + return 0; +} + + diff --git a/c_modern_approach/Fundamentials/README.md b/c_modern_approach/Fundamentials/README.md new file mode 100644 index 0000000..9bde271 --- /dev/null +++ b/c_modern_approach/Fundamentials/README.md @@ -0,0 +1,13 @@ +# Шаги запуска программы +Preprocessing -> Compiling -> Linking + +## Preprocessing +Первый шаг - команда попадает сюда. Тут препроцессор выполняет команды, которые начинаются с `#`. These commands are called **Directives** + +## Compiling +After Preprocessing app goes to compiler where app is being translated into machine instructions (object code) + +## Linking +Linker combines object code from step 2 with additional code needed for final executable. This code includes library functions + +P.S.: *Сори за микс языков, лень было переключаться в процессе* diff --git a/labs/part1/celcius.c b/labs/part1/celcius.c new file mode 100644 index 0000000..de416f6 --- /dev/null +++ b/labs/part1/celcius.c @@ -0,0 +1,31 @@ +#include +#define LOWER 0 +#define UPPER 300 +#define STEP 20 + +int main() { + float fahr, celsius; + int lower, upper, step; + + fahr = LOWER; + printf("Temperature conversion\n"); + while (fahr <= UPPER) { + celsius = (5.0 / 9.0) * (fahr - 32.0); + printf("%3.0f\t%6.1f\n", fahr, celsius); + fahr = fahr + STEP; + } + + printf("\nNow Celcius -> Fahr table\n"); + lower = 0; + upper = 100; + step = 5; + fahr = 0.0; + celsius = lower; + while (celsius <= upper) { + fahr = (celsius * (9.0 / 5.0)) + 32; + printf("%3.0f\t%6.1f\n", celsius, fahr); + celsius = celsius + step; + } + + return 0; +} diff --git a/labs/part1/hello.c b/labs/part1/hello.c new file mode 100644 index 0000000..2fed10f --- /dev/null +++ b/labs/part1/hello.c @@ -0,0 +1,12 @@ +#include + +int main() { + int div_result; + printf("hello world\n"); + printf("Test\tTab\n"); + printf("Test backspace\b\b\b"); + printf("Test\tc_word\a\n"); + div_result = 6/5; + printf("Result: %d", div_result); + return 0; +}