This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() { | |
| int arr[5] = {3, 5, 4, 7}, idx; | |
| for (idx = 0; idx < 5; idx++) | |
| printf("item addr: %i | %p \n", *(arr + idx) ,arr + idx); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void matrix() { | |
| char mtx[2][3] = {{"mat"}, {"rix"}}; | |
| mtx[1][1] = '1'; | |
| for (int i = 0; i < 2; i++) { | |
| printf("%i)idx: [%c] [%c] [%c]\n", i, mtx[i][0], mtx[i][1], mtx[i][2]); | |
| } | |
| printf("\tsizeof arr = %i bytes\n", sizeof(mtx)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void wrt_file(char * dat, char * filename) { | |
| FILE *file = fopen(filename, "w"); | |
| fprintf(file, dat); | |
| fclose(file); | |
| } | |
| void rd_file(char * filename, char * file_str) { | |
| int c; | |
| int idx = 0; | |
| FILE *file; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void lnrd(char * str) { | |
| int idx = 0; | |
| while (true) { | |
| char ch = getchar(); | |
| if (ch == '\n') | |
| break; | |
| str[idx] = ch; | |
| idx++; | |
| } | |
| str[idx++] = '\0'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct author { | |
| int age; | |
| char uname[80]; | |
| char stack[80]; | |
| }; | |
| struct author new_developer() { | |
| struct author new; | |
| printf("Username: "); | |
| lnrd(new.uname); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Only INT, don't trying use arrays with char | |
| void foreach(int *arr, int len, void (*callback) (int item, int idx)) { | |
| unsigned idx = 0; | |
| for (idx; idx < len; idx++) | |
| callback(arr[idx], idx); | |
| } | |
| int main() { | |
| int arr[] = {1, 3, 5, 6}; | |
| int arr_len = sizeof arr / sizeof arr[0]; | |
| void cb (int n, int idx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int system(const char *shell); | |
| int main() { | |
| system("whoami"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() { | |
| const char str = "We do not cares ;)"; | |
| return atoi(str); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create the volume in advance | |
| docker volume create --driver local \ | |
| --opt type=none \ | |
| --opt device=/home/user/test \ | |
| --opt o=bind \ | |
| test_vol | |
| # create on the fly with --mount | |
| docker run -it --rm \ | |
| --mount type=volume,dst=/container/path,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=/home/user/test \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| // My solution | |
| void rvrs(char * str, char * reversed_str, unsigned len) { | |
| str += len - 1; | |
| while (str[0]) { | |
| *reversed_str = str[0]; | |
| str -= 1; | |
| reversed_str++; |
OlderNewer