diff --git a/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c b/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c index b8c74f1..f6743f3 100644 --- a/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c +++ b/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c @@ -1,6 +1,6 @@ // File name: ExtremeC_exampels_chapter4_5.c // Description: Example 4.5 -int main(int agrc, char** argv) { +int main(int argc, char** argv) { return 0; } diff --git a/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c b/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c index 153acf4..9452fba 100644 --- a/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c +++ b/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c @@ -4,6 +4,10 @@ #include // For printf function #include // For C library's heap memory functions +#if defined(__APPLE__) && defined(__MACH__) + #include +#endif + void print_mem_maps() { #ifdef __linux__ FILE* fd = fopen("/proc/self/maps", "r"); @@ -17,6 +21,11 @@ void print_mem_maps() { printf("> %s", line); } fclose(fd); +#elif defined(__APPLE__) && defined(__MACH__) + char command[256]; + pid_t pid = getpid(); + sprintf(command, "vmmap %d", pid); + system(command); #endif } diff --git a/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c b/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c index 71686d0..873cd97 100644 --- a/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c +++ b/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c @@ -58,8 +58,8 @@ int not_friendly_sum(int* matrix, int rows, int columns) { int main(int argc, char** argv) { if (argc < 4) { - printf("Usage: %s [print|friendly-sum|not-friendly-sum] "); - printf("[number-of-rows] [number-of-columns]\n", argv[0]); + printf("Usage: %s [print|friendly-sum|not-friendly-sum] ", argv[0]); + printf("[number-of-rows] [number-of-columns]\n"); exit(1); } char* operation = argv[1];