Skip to content

5eed1ab/A1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The ABCs of computing

  • A
    • ASCII (American Standard Code for Information Interchange) is a fundamental character encoding standard that assigns unique numbers (0-127) to 128 basic characters—including English letters (A-Z, a-z), digits (0-9), punctuation, and control codes—allowing computers and devices to communicate and display text universally, forming the basis for modern encoding like Unicode.
  • B
    • Bit manipulation is the process of algorithmically changing bits, the smallest units of data in a computer
  • C
    • The C programming language is a powerful, general-purpose, procedural language developed in the early 1970s by Dennis Ritchie at Bell Labs. It is widely influential and remains one of the most popular programming languages, primarily used for system-level programming where performance and low-level memory access are critical.

A1

  • 2.6GHz quad-core Intel Core i7 (Turbo Boost up to 3.6GHz)
  • 16GB (two 8GB) of 1600MHz DDR3 memory
  • 1TB (5400-rpm) hard drive
  • 2TB SSD Crucial

Catalina

Omarchy

curl -O https://iso.omarchy.org/omarchy-3.1.7.iso
diskutil list # what disk is usb?
sudo dd if=omarchy-3.1.7.iso of=/dev/usb_disk bs=1M conv=sync

a1.c modified to use %s, %c, %d,%i %p and \n in printf

  • int is a data type which stores whole numbers

    • int i
  • char is a byte storing a single ASCII value like '?' or 63

    • char character
  • C does not have a String type to easily create string variables.

    • Instead, you must use the char type and create an array of characters.
    • char characters[]
    • char string[]
  • for loop loops through a block of code a number of times.

    • for(i=0;i<=7;i++)

printf format specifiers and escape sequences

format description
%s The char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating NUL character; if a precision is specified, no more than the number specified are written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating NUL character.
%c The int argument is converted to an unsigned char, and the resulting character is written.
%d, %i The int argument is converted to signed decimal notation. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. The default precision is 1. When 0 is printed with an explicit precision 0, the output is empty.
%p The void * pointer argument is printed in hexadecimal
\n The ASCII value 10 represents the Line Feed (LF) control character, often shown as \n, used to start a new line in text

String Shenanigans

format a table with character %c, decimal %d, and use pointer%p to display memory address

char string[]="String";

string[] string[0]=S string[1]=t string[2]=r string[3]=i string[4]=n string[5]=g string[6]=\0
decimal 83 116 114 105 110 103 0
address 0x16b0e6f14 0x16b0e6f15 0x16b0e6f16 0x16b0e6f17 0x16b0e6f18 0x16b0e6f19 0x16b0e6f1a

make

gcc a1.c -o a1

./a1

Hello, is there a s in string[]?

|string[]     | string[0]=S | string[1]=t | string[2]=r | string[3]=i | string[4]=n | string[5]=g | string[6]=\0|
|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|
|decimal      |      83     |     116     |     114     |     105     |     110     |     103     |       0     |
|address      | 0x16b0e6f14 | 0x16b0e6f15 | 0x16b0e6f16 | 0x16b0e6f17 | 0x16b0e6f18 | 0x16b0e6f19 | 0x16b0e6f1a |

Read the man pages

man Description
man less less - opposite of more
man man the man utility finds and displays online manual documentation pages
man make to determine automatically which pieces of a large program need to be recompiled
man ascii ascii – octal, hexadecimal and decimal ASCII character sets
man printf printf – formatted output
man 3 printf the printf() family of functions produces output according to a format as described below.
man 3 stdio the standard I/O library provides a simple and efficient buffered stream I/O interface

About

5E:ED:1A:B0:0A:A1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published