Example 1: Test the Patch
$ ./example.o
Put string to split: hello world
First str: Hello
Second str: World
Put string to split:$ sudo gdb ./example.o -p `pgrep example.o`
0x00007f474d3a8081 in __GI___libc_read (fd=0, buf=0x55beb275a670, nbytes=1024)
at ../sysdeps/unix/sysv/linux/read.c:27
27 ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
(gdb)6 char** split(char* input) {
7 char** result = malloc(10*sizeof(char*));
8 result[0] = input;
9 int j = 1;20 int getInputAndRun() {
21 char input[100];
22 printf("Put string to split: ");
23 fgets(input, 100, stdin);
24 if (strcmp(input, "exit") == 0) return -1;
25 else {
26 char** result = split(input);
27 *result[0] = toupper(result[0][0]);
28 *result[1] = toupper(result[1][0]);
29 printf("First str: %s\n", result[0]);
30 printf("Second str: %s\n", result[1]);
31 return 0;Last updated