I am new to programming. I know that a computer executes instructions in the order they are given.
I'm learning C and I wrote this:
#include <stdlib.h>
#include <stdio.h>
int comp(const char *a, const char *b) {
return *a - *b;
}
int main() {
char str[] = "Hello, world! I'm learning C and it's awesome!";
qsort(str, sizeof(str) - 1, sizeof(char), comp); // -1 because of NUL-terminator.
puts(str);
return 0;
}
However, when I want to sort multiple very large arrays, this can take a while. My computer has multiple processing cores so I want to take advantage of that. Is that possible? Can code run in parallel and how would I do that?
P.S. I know I have to profile the code before optimizing it, but for now assume this is a very slow operation.