Skip to content

YoungHaKim7/c_project

Repository files navigation

Link


vim tab setting[🔝]

set tabstop=2
set shiftwidth=2

C Operator Precedence[🔝]

Precedence Operator Description Associativity
1 ++ -- Suffix/postfix increment and decrement Left-to-right
() Function call
[] Array subscripting
. Structure and union member access
-> Structure and union member access through pointer
(type){list} Compound literal(C99)
2 ++ -- Prefix increment and decrement[note 1] Right-to-left
+ - Unary plus and minus
! ~ Logical NOT and bitwise NOT
(type) Cast
* Indirection (dereference)
& Address-of
sizeof Size-of[note 2]
_Alignof Alignment requirement(C11)
3 * / % Multiplication, division, and remainder Left-to-right
4 + - Addition and subtraction
5 << >> Bitwise left shift and right shift
6 < <= For relational operators < and ≤ respectively
> >= For relational operators > and ≥ respectively
7 == != For relational = and ≠ respectively
8 & Bitwise AND
9 ^ Bitwise XOR (exclusive or)
10 | Bitwise OR (inclusive or)
11 && Logical AND
12 || Logical OR
13 ?: Ternary conditional[note 3] Right-to-left
14[note 4] = Simple assignment
+= -= Assignment by sum and difference
*= /= %= Assignment by product, quotient, and remainder
<<= >>= Assignment by bitwise left shift and right shift
&= ^= |= Assignment by bitwise AND, XOR, and OR
15 , Comma Left-to-right
  1. The operand of prefix ++ and -- can't be a type cast. This rule grammatically forbids some expressions that would be semantically invalid anyway. Some compilers ignore this rule and detect the invalidity semantically.
  2. The operand of sizeof can't be a type cast: the expression sizeof (int) * p is unambiguously interpreted as (sizeof(int)) * p, but not sizeof((int)*p).
  3. The expression in the middle of the conditional operator (between ? and :) is parsed as if parenthesized: its precedence relative to ?: is ignored.
  4. Assignment operators' left operands must be unary (level-2 non-cast) expressions. This rule grammatically forbids some expressions that would be semantically invalid anyway. Many compilers ignore this rule and detect the invalidity semantically. For example, e = a < d ? a++ : a = d is an expression that cannot be parsed because of this rule. However, many compilers ignore this rule and parse it as e = ( ((a < d) ? (a++) : a) = d ), and then give an error because it is semantically invalid.

When parsing an expression, an operator which is listed on some row will be bound tighter (as if by parentheses) to its arguments than any operator that is listed on a row further below it. For example, the expression *p++ is parsed as *(p++), and not as (*p)++.

Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction. For example, the expression a=b=c is parsed as a=(b=c), and not as (a=b)=c because of right-to-left associativity.

[edit] Notes

Precedence and associativity are independent from order of evaluation.

The standard itself doesn't specify precedence levels. They are derived from the grammar.

In C++, the conditional operator has the same precedence as assignment operators, and prefix ++ and -- and assignment operators don't have the restrictions about their operands.

Associativity specification is redundant for unary operators and is only shown for completeness: unary prefix operators always associate right-to-left (sizeof ++*p is sizeof(++(*p))) and unary postfix operators always associate left-to-right (a[1][2]++ is ((a[1])[2])++). Note that the associativity is meaningful for member access operators, even though they are grouped with unary postfix operators: a.b++ is parsed (a.b)++ and not a.(b++).

[edit] References

  • C17 standard (ISO/IEC 9899:2018):
  • A.2.1 Expressions
  • C11 standard (ISO/IEC 9899:2011):
  • A.2.1 Expressions
  • C99 standard (ISO/IEC 9899:1999):
  • A.2.1 Expressions
  • C89/C90 standard (ISO/IEC 9899:1990):
  • A.1.2.1 Expressions

[edit] See also

Order of evaluation of operator arguments at run time.

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b

a(...)
a, b
(type) a
a ? b : c
sizeof


_Alignof
(since C11)

C++ documentation for C++ operator precedence

C코드를 ll로 변환 후 Assembly ❤️바꾸는 방법(LLVM&Assembly코드는 M1pro arm64기계 기준임macOS)otool활용[🔝]

https://economiceco.tistory.com/14882


유료$paid독하게 되새기는 C 프로그래밍[🔝]

https://inf.run/W34T

https://www.inflearn.com/course/%EB%8F%85%ED%95%98%EA%B2%8C-%EB%90%98%EC%83%88%EA%B8%B0%EB%8A%94-c%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D/

자습서: VS Code를 사용하여 Mac에서 C 프로그램 디버깅[🔝]

https://youtu.be/wKjFVyDbSpA?si=iDI2RC3mMhSeCXSe

VS Code에서 C++ 프로젝트 디버그[🔝]

https://youtu.be/G9gnSGKYIg4?si=xxmdCBQSWqa0dtSs

고생하면서 배우는 C언어 (일본어)苦しんで覚えるC言語[🔝]

https://9cguide.appspot.com/index.html

C Programming Full Course for free 🕹️ (4hr)[🔝]

https://youtu.be/87SH2Cn0s9A

C / C++ | freeCodeCamp.org[🔝]

https://youtube.com/playlist?list=PLWKjhJtqVAbmUE5IqyfGYEYjrZBYzaT4m

Microsoft C++, C, and Assembler documentation(C MSDN)[🔝]

  • Learn how to use C++, C, and assembly language to develop applications, services, and tools for your platforms and devices.

https://learn.microsoft.com/en-us/cpp/?view=msvc-170

c-language(MS)[🔝]

https://learn.microsoft.com/en-us/cpp/c-language/?view=msvc-170

MicroSoft Learn (Samples C)[🔝]

https://learn.microsoft.com/en-us/samples/browse/?languages=c

Smile Han의 C 언어 프로그래밍[🔝]

https://youtube.com/playlist?list=PLJqaIeuL7nuFgbxCyhtZ7xBUNhdV9Qy5R


The LLVM Compiler Infrastructure[🔝]

https://llvm.org/


Creating the Node of a Single Linked List[🔝]

https://youtu.be/DneLxrPmmsw


C Programming & Data Structures Series

https://youtube.com/playlist?list=PLBlnK6fEyqRhX6r2uhhlubuF5QextdCSM




C Language Tutorials In Hindi __ 1[🔝]

https://youtube.com/playlist?list=PLu0W_9lII9aiXlHcLx-mDH1Qul38wD3aR


How I program C | Eskil Steenberg ___ 2[🔝]

https://youtu.be/443UNeGrFoM


Advanced C: The UB and optimizations that trick good programmers. | Eskil Steenberg[🔝]

https://youtu.be/w3_e9vZj7D8


Modern C and What We Can Learn From It - Luca Sas [ ACCU 2021 ][🔝]

https://youtu.be/QpAhX-gsHMs


C Language Tutorial Videos[🔝]

https://youtube.com/playlist?list=PLVlQHNRLflP8IGz6OXwlV_lgHgc72aXlh



build.sh[🔝]

#!/bin/bash

clang -pthread -lm -Wall -Wextra -ggdb -o main main.c

or 

gcc -pthread -lm -Wall -Wextra -ggdb -o main main.c


delete.sh[🔝]

#!/bin/bash

rm -rf main main.dSYM


xxd 명령어 이해하기[🔝]

https://www.tutorialspoint.com/unix_commands/xxd.htm

  • 예시 exercise/004string/main.c 참고
$ ./main "ready" "set" "go" | xxd -g 1

00000000: 61 72 67 76 20 3d 20 30 78 31 36 64 37 30 33 32  argv = 0x16d7032
00000010: 61 30 0a 61 72 67 76 5b 30 5d 20 3d 20 30 78 31  a0.argv[0] = 0x1
00000020: 36 64 37 30 33 34 64 38 0a 2e 2f 6d 61 69 6e 0a  6d7034d8../main.
00000030: 61 72 67 76 5b 31 5d 20 3d 20 30 78 31 36 64 37  argv[1] = 0x16d7
00000040: 30 33 34 64 66 0a 72 65 61 64 79 0a 61 72 67 76  034df.ready.argv
00000050: 5b 32 5d 20 3d 20 30 78 31 36 64 37 30 33 34 65  [2] = 0x16d7034e
00000060: 35 0a 73 65 74 0a 61 72 67 76 5b 33 5d 20 3d 20  5.set.argv[3] =
00000070: 30 78 31 36 64 37 30 33 34 65 39 0a 67 6f 0a     0x16d7034e9.go.


C Program in Hindi: C Tutorial In Hindi[🔝]

Basic Structure of C Program in Hindi


Java vs C Data Represintation(Sizse of objects(in bytes))[🔝]

Sizes of objects(in bytes)
Java
data type
C
data type
Typical
32-bit
x86-64
boolean bool 1 1
byte char 1 1
char 2 2
short short int 2 2
int int 4 4
float float 4 4
long int 4 8
double double 8 8
long long long 8 8
long double 8 16
(reference) pointer * 4 8


자료 구조[🔝]

https://github.com/YoungHaKim7/c_project/tree/main/exercise/002stack

자료 구조(Well-known data structures)
유형(Type) 컬렉션(Collection) , 컨테이너(Container)
추상ADT
Abstract Data Type
연관 배열(Associative array), 우선 순위 덱(Priority Deque), 덱(Deque), 리스트(List),
멀티맵, 우선순위 큐(Priority Queue), 큐(Queue),
집합 (멀티셋, 분리 집합),
스택(stack)
Associative array(Multimap, Retrieval Data Structure), List, StackQueue(Double-ended queue), Priority queue(Double-ended priority queue), Set(Multiset, Disjoint-set)
배열(Array) 비트 배열(Bit Array), 환형 배열(Circular array), 동적 배열(Dynamic Array),
해시 테이블(Hash Table), 해시드 어레이 트리(Hashed Array Tree), 희소 배열(Sparse array)
연결형(Linked) 연관 리스트(Association list),

연결 리스트(Linked List) - 단일연결(Singly Linked List), 이중연결(Doubly Linked List), 원형 연결(Circular Linked List)

Association list,
Linked list, Skip list, Unrolled linked list, XOR linked list
트리(Trees) B 트리,
이진 탐색 트리(AA, AVL, 레드-블랙, 자가 균형, splay)
힙(이진 힙, 피보나치) ,
R 트리( R*, R+, 힐버트),
트리(해시 트리)

B-tree, Binary search tree(AA tree, AVL tree, Red–black tree, Self-balancing tree, Splay tree),
Heap(Binary heap, Binomial heap, Fibonacci heap),
R-tree(R* tree, R+ tree, Hilbert R-tree), Trie Hash tree
그래프(Graphs) 이진 결정 다이어그램
Binary decision diagram, Directed acyclic graph, Directed acyclic word graph


Big-O Cheat Sheet(그림으로 이쁘게)[🔝]

https://dev.to/deciduously/big-o-cheat-sheet-3i7d






C Languages Tutorial[🔝]

https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md#c

C Tutorial 2[🔝]

https://www.tutorialspoint.com/cprogramming/

"Let us C - Yashavant Kanetkar (PDF) (🗃️ latest 14th edition)

Compilers[🔝]

Use every available and reasonable set of warning options. Some warning options only work with optimizations enabled, or work better the higher the chosen level of optimization is, for example -Wnull-dereference with GCC.

You should use as many compilers as you can for your platform(s). Each compiler implements the standard slightly differently and supporting multiple will help ensure the most portable, most reliable code.

GCC / Clang[🔝]

-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic

  • use these and consider the following (see descriptions below)

see descriptions below

  • -pedantic - Warn on language extensions

  • -Wall -Wextra reasonable and standard

  • -Wshadow warn the user if a variable declaration shadows one from a parent context

  • -Wnon-virtual-dtor warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors

  • -Wold-style-cast warn for c-style casts

  • -Wcast-align warn for potential performance problem casts -Wunused warn on anything being unused

  • -Woverloaded-virtual warn if you overload (not override) a virtual function

  • -Wpedantic (all versions of GCC, Clang >= 3.2) warn if non-standard C++ is used

  • -Wconversion warn on type conversions that may lose data

  • -Wsign-conversion (Clang all versions, GCC >= 4.3) warn on sign conversions

  • -Wmisleading-indentation (only in GCC >= 6.0) warn if indentation implies blocks where blocks do not exist

  • -Wduplicated-cond (only in GCC >= 6.0) warn if if / else chain has duplicated conditions

  • -Wduplicated-branches (only in GCC >= 7.0) warn if if / else branches have duplicated code

  • -Wlogical-op (only in GCC) warn about logical operations being used where bitwise were probably wanted

  • -Wnull-dereference (only in GCC >= 6.0) warn if a null dereference is detected

  • -Wuseless-cast (only in GCC >= 4.8) warn if you perform a cast to the same type

  • -Wdouble-promotion (GCC >= 4.6, Clang >= 3.8) warn if float is implicitly promoted to double

  • -Wformat=2 warn on security issues around functions that format output (i.e., printf)

  • -Wlifetime (only special branch of Clang currently) shows object lifetime issues

  • -Wimplicit-fallthrough Warns when case statements fall-through. (Included with -Wextra in GCC, not in clang)

Consider using -Weverything and disabling the few warnings you need to on Clang

  • -Weffc++ warning mode can be too noisy, but if it works for your project, use it also.

https://github.com/cpp-best-practices/cppbestpractices/blob/master/02-Use_the_Tools_Available.md

About

c_project & My Youtube Channel - GlobalYoung https://www.youtube.com/@GlobalYoung7

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published