- Pointers
- Dynamic Memory Management
- Structures
- Unions
- Enumarations
- Bitwise Operations
- String Library
- Signal Handling
- C Process Control
- My Other Awesome Lists
- Contributing
- Contributors
Function Declarations: A function can be declared several times in a program, butall declarationsfor a given function must be compatible;- the return type is the same
- the parameters have the same type.
float square(float x);
Function declarations do not allocate storage.
Function Definitions:float square(float x) { return x*x; }
int ival;
double darray[5];- ival has type int; we say &ival is a
"pointer to int." - darray has type double[5]; we say &darray is a
"pointer to an array of five doubles." - darray[3] has type double; we say &darray[3] is a
"pointer to double."
You can find more details at the link
#include <stdlib.h>
void *malloc(size_t size);int ptrIArray[10];malloc() takes a single argument (the amount of memory to allocate in bytes).
#include <stdlib.h>
void *calloc(size_t nelem, size_t elsize);Allocates memory for an array of num objects of size and initializes all bytes in the allocated storage to zero.
realloc() is used to resize previously allocated memory (from malloc(), calloc(), or a previous realloc() call). It allows you to:
- increase array size
- shrink array size
- avoid losing existing data
- avoid manually copying the old array
#include <stdlib.h>
void *realloc(void *ptr, size_t size);- If ptr is a
null pointer, realloc() shall be equivalent to malloc() for the specified size.
#include <stdlib.h>
void free(void *ptr);Releases the specified block of memory back to the system.
You can find more details at the link
A struct in C is a user-defined data type grouped together under one name. Its members can be of different data types (unlike arrays).
struct Person {
char name[50];
int age;
float height;
};
int main() {
struct Person p1;
// Assign values
strcpy(p1.name, "Alex");
p1.age = 25;
p1.height = 1.75f;
printf("Name:\t%s\n", p1.name);
printf("Age:\t%d\n", p1.age);
printf("Height:\t%.2f\n", p1.height);
return 0;
}A union is like a struct, but all members share the same memory location. This means:
- A union can store only one member at a time
- Size of union = size of its largest member
- Writing to one member affects all others (because they
overlap in memory)
union Data {
int ival;
float fval;
char cval;
};
int main() {
union Data Dval;
Dval.ival = 26;
printf("Dval.ival = %d\n", Dval.ival);
Dval.fval = 3.14;
printf("Dval.fval = %.2f\n", Dval.fval);
Dval.cval = 'A';
printf("Dval.cval = %c\n", Dval.cval);
return 0;
}An enumeration (enum) is a user-defined data type that lets you assign names to integer constants.
Basic EnumExampleenum Day { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY }; int main() { enum Day today = SATURDAY; printf("Today is day number: %d\n", today); return 0; }
You can find more details at the link
| Byte string | Wide string | Description |
|---|---|---|
strcpy |
wcscpy |
Copies one string to another |
strncpy |
wcsncpy |
Writes exactly n bytes/characters, copying from source or adding nulls |
strcat |
wcscat |
Appends one string to another |
strncat |
wcsncat |
Appends no more than n bytes/characters from one string to another |
strxfrm |
wcsxfrm |
Transforms a string according to the current locale |
You can find more details at the link
| Signal Number | Name |
Meaning | Catchable? |
|---|---|---|---|
| 1 | SIGHUP | Hangup detected | β Yes |
| 2 | SIGINT | Interrupt (Ctrl+C) | β Yes |
| 3 | SIGQUIT | Quit (Ctrl+) | β Yes |
| 4 | SIGILL | Illegal instruction | β Yes |
| 5 | SIGTRAP | Trace/breakpoint trap | β Yes |
| 6 | SIGABRT | Abort | β Yes |
| 7 | SIGBUS | Bus error | β Yes |
| 8 | SIGFPE | Floatingβpoint exception | β Yes |
| 9 | SIGKILL | Kill immediately | β No |
| 10 | SIGUSR1 | User-defined signal 1 | β Yes |
| 11 | SIGSEGV | Segmentation fault | β Yes |
| 12 | SIGUSR2 | User-defined signal 2 | β Yes |
| 13 | SIGPIPE | Broken pipe | β Yes |
| 14 | SIGALRM | Alarm clock | β Yes |
| 15 | SIGTERM | Termination request | β Yes |
| 16 | SIGSTKFLT | Stack fault (Linux specific) | β Yes |
| 17 | SIGCHLD | Child stopped/terminated | β Yes |
| 18 | SIGCONT | Continue executing | β Yes |
| 19 | SIGSTOP | Stop the process | β No |
| 20 | SIGTSTP | Stop (Ctrl+Z) | β Yes |
| 21 | SIGTTIN | Background read from TTY | β Yes |
| 22 | SIGTTOU | Background write to TTY | β Yes |
| 23 | SIGURG | Urgent condition on socket | β Yes |
| 24 | SIGXCPU | CPU time limit exceeded | β Yes |
| 25 | SIGXFSZ | File size limit exceeded | β Yes |
| 26 | SIGVTALRM | Virtual alarm clock | β Yes |
| 27 | SIGPROF | Profiling timer expired | β Yes |
| 28 | SIGWINCH | Window size change | β Yes |
| 29 | SIGIO | I/O now possible | β Yes |
| 30 | SIGPWR | Power failure | β Yes |
| 31 | SIGSYS | Bad system call | β Yes |
You can find more details at the link
- cJSON - Ultralightweight JSON parser in ANSI C.
- Doxygen - Doxygen is a widely-used documentation generator tool in software development.
- MSVC & GCC & Clang - installation step of MSVC/GCC/Clang compiler in Windows
- GCC & Clang - installation step of GCC/Clang compiler in Linux
- OnlineGDB - Online compiler and debugger for C/C++
You can access the my other awesome lists here
Contributions of any kind welcome, just follow the guidelines!
