2022-06-02 13:08:59 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
2022-06-06 00:16:44 +00:00
|
|
|
#include <stdio.h>
|
2022-06-05 22:02:54 +00:00
|
|
|
#include <stdlib.h>
|
2022-06-06 00:26:32 +00:00
|
|
|
#include <errno.h>
|
2022-06-02 23:36:04 +00:00
|
|
|
|
2022-06-07 06:02:23 +00:00
|
|
|
#include <stdbool.h>
|
2022-06-06 04:57:25 +00:00
|
|
|
#include <inttypes.h>
|
2022-06-05 22:02:54 +00:00
|
|
|
|
2022-06-07 09:26:13 +00:00
|
|
|
#include <string.h>
|
2022-06-07 06:02:23 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2022-06-07 09:26:13 +00:00
|
|
|
int test() {
|
|
|
|
static int a = 2;
|
|
|
|
a += 1;
|
|
|
|
return a;
|
2022-06-07 06:02:23 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 02:17:57 +00:00
|
|
|
void wack() {
|
|
|
|
printf("BYE!!!\n");
|
|
|
|
}
|
|
|
|
|
2022-06-06 04:57:25 +00:00
|
|
|
int main(int argc, char** argv) {
|
2022-06-08 02:17:57 +00:00
|
|
|
atexit(wack);
|
|
|
|
|
2022-06-08 02:36:49 +00:00
|
|
|
char* path_env = getenv("PATH");
|
|
|
|
char *ctx, *path_token = strtok_r(path_env, ";", &ctx);
|
|
|
|
while(path_token) {
|
|
|
|
printf("%s\n", path_token);
|
|
|
|
path_token = strtok_r(NULL, ";", &ctx);
|
|
|
|
}
|
|
|
|
|
2022-06-07 09:26:13 +00:00
|
|
|
test();
|
|
|
|
char input[] = "A bird came down the walk";
|
|
|
|
printf("Parsing the input string '%s'\n", input);
|
|
|
|
char *token = strtok(input, " ");
|
|
|
|
while(token) {
|
|
|
|
printf("%s\n", token);
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
}
|
2022-06-08 02:17:57 +00:00
|
|
|
|
2022-06-07 09:26:13 +00:00
|
|
|
printf("Contents of the input string now: '");
|
|
|
|
for(size_t n = 0; n < sizeof input; ++n)
|
|
|
|
input[n] ? printf("%c", input[n]) : printf("\\0");
|
|
|
|
printf("'");
|
2022-06-06 04:57:25 +00:00
|
|
|
return 0;
|
2022-06-08 02:17:57 +00:00
|
|
|
}
|