Skip to content

Commit

Permalink
✒️Rename all README to TASKS
Browse files Browse the repository at this point in the history
  • Loading branch information
bekalue committed Aug 27, 2023
1 parent 2cfcef5 commit 3f5633f
Show file tree
Hide file tree
Showing 36 changed files with 6,246 additions and 0 deletions.
243 changes: 243 additions & 0 deletions 0x00-hello_world/TASKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# 0x00-hello_world
>Project Done in 1 Day
![Betty style](https://img.shields.io/badge/betty-style%20guide-purple?style=round-square)

## Learning objectives
> needed to be [explaied](https://fs.blog/feynman-learning-technique/) after the project.
* Why __C__ programming is awesome
* Who invented C
* Who are [Dennis Ritchie](https://en.wikipedia.org/wiki/Dennis_Ritchie), [Brian Kernighan](https://www.youtube.com/watch?v=de2Hsvxaf8M) and Linus Torvalds
* What happens when you type `gcc main.c`
* What is an entry point
* What is `main`
* How to print text using `printf`, `puts` and `putchar`
* How to get the size of a specific type using the unary operator `sizeof`
* How to compile using `gcc`
* What is the default program name when compiling with `gcc`
* What is the official __C__ coding style and how to check your code with [betty-style](https://github.com/holbertonschool/Betty/wiki)
* How to find the right header to include in your source code when using a standard library function
* How does the `main` function influence the return value of the program

## Resourcess Used

* [0x00. C - Hello, World](https://www.youtube.com/watch?v=co0b0xLEuRM&t=11s)
* [Why __c__ Programming is Awesome](https://www.youtube.com/watch?v=smGalmxPVYc)
* [Learning to Program in __c__ Part |](https://www.youtube.com/watch?v=rk2fK2IIiiQ)
* [Learning to Program in __c__ Part ||](https://www.youtube.com/watch?v=FwpP_MsZWnU)
* [Understanding __c__ Program Compilation Process](https://www.youtube.com/watch?v=VDslRumKvRA)
* [Hash-Bang Under the Hood](https://twitter.com/unix_byte/status/1024147947393495040?s=21)
* [Linus Torvalds on __c__ vs __c++__](http://harmful.cat-v.org/software/c++/linus)
* man `gcc`
* man 3 `printf`
* man `puts`
* man `putchar`

## Betty linter

To run the Betty linter just with command betty <filename>:
+ Go to the [Betty](https://github.com/holbertonschool/Betty) repository
+ Clone the repo to your local machine
+ cd into the Betty directory
+ Install the linter with sudo ./install.sh
+ Once saved, exit file and change permissions to apply to all users with `chmod a+x betty`
+ Move the `betty` file into `/bin/` directory or somewhere else in your `$PATH` with `sudo mv betty /bin/`
+ You can now type `betty <filename>` to run the Betty linter!

## Tasks Completed

+ [x] 0\. Preprocessor<br/>_**[0-preprocessor](0-preprocessor)**_ runs a C file through the preprocessor and save the result into another file. The C file name will be saved in the variable `$CFILE`. The output would be saved in the file `c`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ export CFILE=main.c
bekalue@BEKALU-PC:~/c/0x00$ ./0-preprocessor
bekalue@BEKALU-PC:~/c/0x00$ tail c
# 942 "/usr/include/stdio.h" 3 4

# 2 "main.c" 2


# 3 "main.c"
int main(void)
{
return (0);
}
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 1\. Compiler<br/>_**[1-compiler](1-compiler)**_ compiles a C file but does not link. The C file name will be saved in the variable `$CFILE`. The output file would be named the same as the C file, but with the extension `.o` instead of `.c`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ export CFILE=main.c
bekalue@BEKALU-PC:~/c/0x00$ cat main.c
#include <stdio.h>
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
return (0);
}
bekalue@BEKALU-PC:~/c/0x00$ ./1-compiler
bekalue@BEKALU-PC:~/c/0x00$ ls
0-preprocessor 1-compiler c main.o
Makefile 100-intel main.c main.s
bekalue@BEKALU-PC:~/c/0x00$ cat -v main.o | head
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^A^@>^@^A^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^P^B^@^@^@^@^@^@^@^@^@^@@^@^@^@^@^@@^@^K^@^H^@UHM-^IM-eM-8^@^@^@^@]M-C^@GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609^@^T^@^@^@^@^@^@^@^AzR^@^Ax^P^A^[^L^G^HM-^P^A^@^@^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~/c/0x00$
```
+ [x] 2\. Assembler<br/>_**[2-assembler](2-assembler)**_ generates the assembly code of a C code and save it in an output file. The C file name will be saved in the variable `$CFILE`. The output file would be named the same as the C file, but with the extension `.s` instead of `.c`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ export CFILE=main.c
bekalue@BEKALU-PC:~/c/0x00$ cat main.c
#include <stdio.h>

/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
return (0);
}
bekalue@BEKALU-PC:~/c/0x00$ ./2-assembler
bekalue@BEKALU-PC:~/c/0x00$ ls
0-preprocessor 1-compiler 2-assembler c main.c main.s Makefile
bekalue@BEKALU-PC:~/c/0x00$ cat main.s
.file "main.c"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609"
.section .note.GNU-stack,"",@progbits
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 3\. Name<br/>_**[3-name](3-name)**_ compiles a C file and creates an executable named `cisfun`. The C file name will be saved in the variable `$CFILE`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ export CFILE=main.c
bekalue@BEKALU-PC:~/c/0x00$ cat main.c
#include <stdio.h>
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
return (0);
}
bekalue@BEKALU-PC:~/c/0x00$ ./3-name
bekalue@BEKALU-PC:~/c/0x00$ ls
0-preprocessor 1-compiler 3-name cisfun main.o Makefile
100-intel 2-assembler c main.c main.s
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 4\. Hello, puts<br/>_**[4-puts.c](4-puts)**_ prints exactly `"Programming is like building a multilingual puzzle`, followed by a new line using the function `puts` rather than `printf`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 4-puts.c && ./a.out
"Programming is like building a multilingual puzzle
bekalue@BEKALU-PC:~/c/0x00$ echo $?
0
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 5\. Hello, printf<br/>_**[5-printf.c](5-printf.c)**_ prints exactly `with proper grammar, but the outcome is a piece of art,`, followed by a new line using the function `printf` rather than the function `puts`. The program should compile without warning when using the `-Wall` `gcc` option.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 5-printf.c
bekalue@BEKALU-PC:~/c/0x00$ ./a.out
with proper grammar, but the outcome is a piece of art,
bekalue@BEKALU-PC:~/c/0x00$ echo $?
0
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 6\. Size is not grandeur, and territory does not make a nation<br/>_**[6-size.c](6-size.c)**_ prints the size of various types on the computer it is compiled and run on. You might have to install the package `libc6-dev-i386` on your Linux system to test the `-m32` `gcc` option.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ gcc 6-size.c -m32 -o size32 2> /tmp/32
bekalue@BEKALU-PC:~/c/0x00$ gcc 6-size.c -m64 -o size64 2> /tmp/64
bekalue@BEKALU-PC:~/c/0x00$ ./size32
Size of a char: 1 byte(s)
Size of an int: 4 byte(s)
Size of a long int: 4 byte(s)
Size of a long long int: 8 byte(s)
Size of a float: 4 byte(s)
bekalue@BEKALU-PC:~/c/0x00$ ./size64
Size of a char: 1 byte(s)
Size of an int: 4 byte(s)
Size of a long int: 8 byte(s)
Size of a long long int: 8 byte(s)
Size of a float: 4 byte(s)
bekalue@BEKALU-PC:~/c/0x00$ echo $?
0
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 7\. Intel<br/>_**[100-intel](100-intel)**_ generates the assembly code (Intel syntax) of a C code and save it in an output file. The C file name will be saved in the variable `$CFILE`. The output file would be named the same as the C file, but with the extension `.s` instead of `.c`.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ export CFILE=main.c
bekalue@BEKALU-PC:~/c/0x00$ cat main.c
#include <stdio.h>
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
return (0);
}
bekalue@BEKALU-PC:~/c/0x00$ ./100-intel
bekalue@BEKALU-PC:~/c/0x00$ cat main.s
.file "main.c"
.intel_syntax noprefix
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
push rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
mov rbp, rsp
.cfi_def_cfa_register 6
mov eax, 0
pop rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609"
.section .note.GNU-stack,"",@progbits
bekalue@BEKALU-PC:~/c/0x00$
```
+ [x] 8\. UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity<br/>_**[101-quote.c](101-quote.c)**_ prints exactly `and that piece of art is useful" - Dora Korpar, 2015-10-19`, followed by a new line, to the standard error.The functions listed in the NAME section of the man (3) `printf` or man (3) `puts` would not be used. The return value of the program would be 1 and would compile without any warnings when using the `-Wall` `gcc` option.<br/>__Example__:
```c
bekalue@BEKALU-PC:~/c/0x00$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 -o quote 101-quote.c
bekalue@BEKALU-PC:~/c/0x00$ ./quote
and that piece of art is useful" - Dora Korpar, 2015-10-19
bekalue@BEKALU-PC:~/c/0x00$ echo $?
1
bekalue@BEKALU-PC:~/c/0x00$ ./quote 2> q
bekalue@BEKALU-PC:~/c/0x00$ cat q
and that piece of art is useful" - Dora Korpar, 2015-10-19
bekalue@BEKALU-PC:~/c/0x00$ grep printf < 101-quote.c
bekalue@BEKALU-PC:~/c/0x00$ grep put < 101-quote.c
bekalue@BEKALU-PC:~/c/0x00$
```
Loading

0 comments on commit 3f5633f

Please sign in to comment.