-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods
More file actions
116 lines (108 loc) · 4.89 KB
/
Methods
File metadata and controls
116 lines (108 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Description: Various Methods
✓ printf
✓ fprintf - Formatted output to a file stream.
✓ sprintf - Formatted output to a string.
✓ snprintf - Formatted output to a string with size limit (safer).
✓ scanf - Formatted input from stdin.
✓ fscanf - Formatted input from a file stream.
✓ sscanf - Formatted input from a string.
✓ getchar - Read a single character from stdin.
✓ putchar - Write a single character to stdout.
✓ fgets - Read a line from a file stream (safer than gets).
✓ fputs - Write a string to a file stream.
✓ fopen - Open a file.
✓ fclose - Close a file.
✓ fread - Read data from a file.
✓ fwrite - Write data to a file.
✓ fseek - Reposition file pointer.
✓ ftell - Get current file pointer position.
✓ rewind - Set file pointer to beginning.
✓ perror - Print system error message.
✓ feof - Check end-of-file indicator.
✓ ferror - Check error indicator.
✓ clearerr - Clear error and EOF indicators.
✓ fflush - Flush a file stream.
° malloc - Allocate memory.
° calloc - Allocate and clear memory.
° realloc - Resize allocated memory.
° free - Deallocate memory.
° memcpy - Copy memory area.
° memmove - Copy memory area (handles overlapping).
° memset - Fill memory with a constant byte.
° memcmp - Compare memory areas.
° memchr - Search memory for a character.
III. String Manipulation (string.h, stdlib.h)
° strcpy - Copy string (unsafe).
° strncpy - Copy string with size limit (safer).
° strcat - Concatenate strings (unsafe).
° strncat - Concatenate strings with size limit (safer).
° strcmp - Compare strings.
° strncmp - Compare strings with size limit.
° strlen - Get string length.
° strchr - Find first occurrence of character in string.
° strrchr - Find last occurrence of character in string.
° strstr - Find first occurrence of substring.
° strtok - Tokenize string (not reentrant, problematic).
° strtok_r - Reentrant string tokenizer.
° strerror - Get error message string.
° atoi - Convert string to integer.
° atol - Convert string to long integer.
° atoll - Convert string to long long integer.
° atof - Convert string to double.
° strtol - Convert string to long integer with error checking.
° strtoul - Convert string to unsigned long integer with error checking.
° strtod - Convert string to double with error checking.
IV. Process Control (unistd.h, stdlib.h, sys/wait.h)
° fork - Create a new process.
° execve - Execute a program.
° execl, execv, execle, execvp, execvpe - Variants of exec.
° wait - Wait for any child process to terminate.
° waitpid - Wait for a specific child process to terminate.
° exit - Terminate the current process normally.
° _exit - Terminate the current process immediately.
° getenv - Get environment variable.
° setenv - Set environment variable.
° unsetenv - Unset environment variable.
° system - Execute a shell command.
° getpid - Get process ID.
° getppid - Get parent process ID.
° sleep - Suspend execution for a specified number of seconds.
° usleep - Suspend execution for a specified number of microseconds (deprecated, use nanosleep).
V. File System Operations (unistd.h, sys/stat.h, fcntl.h)
° open - Open a file descriptor.
° close - Close a file descriptor.
° read - Read from a file descriptor.
° write - Write to a file descriptor.
° lseek - Reposition file descriptor offset.
° stat - Get file status.
° fstat - Get file status from file descriptor.
° lstat - Get file status from symbolic link.
° mkdir - Create a directory.
° rmdir - Remove a directory.
° unlink - Delete a name and possibly the file it refers to.
° rename - Change the name or location of a file.
° chmod - Change file permissions.
° chown - Change file owner and group.
∆ time - Get current time as time_t.
∆ ctime - Convert time_t to string.
∆ gmtime - Convert time_t to UTC tm structure.
∆ localtime - Convert time_t to local tm structure.
∆ mktime - Convert tm structure to time_t.
∆ strftime - Format time into a string.
∆ difftime - Compute difference between two time_t values.
VII. Utility & Miscellaneous (stdlib.h, unistd.h, limits.h, etc.)
∆ abs, labs, llabs - Absolute value of integer types.
∆ rand - Generate a pseudo-random integer.
∆ srand - Seed the pseudo-random number generator.
∆ qsort - Quicksort array.
∆ bsearch - Binary search array.
∆ getopt - Parse command-line options.
∆ gethostname - Get the name of the current host.
∆ sysconf - Get system configuration information.
∆ exit - Terminate process (already listed, but important enough to reinforce).
VIII. Concurrency (pthread.h - often linked separately, but core to libc functionality on many systems)
∆ pthread_create - Create a new thread.
∆ pthread_join - Wait for a thread to terminate.
∆ pthread_mutex_init
∆ pthread_mutex_lock,
∆ pthread_mutex_unlock - Basic mutex operations for thread synchronization.