I am making a qna game that will take 5 random questions from a pool of 10 and present them to the user.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
char* questions(){
static char* er[10] = { //strings in "" are stored in memory, pointer tells the compiler to access the content of said memory
"2+2", //ans 4
"4-5", //ans -1
"10*10", //ans 100
"17*3", //ans 51
"9/3", //ans 3
"45+24+35-68", //ans 36
"4-2", //ans 2
"592-591", //ans 1
"8+3", //ans 11
"9*9" //answer 81
};
return *er;
}
int main()
{
int i;
char *erts;
erts = questions();
for(i = 0; i<10; i++){
printf("%s", erts[i]);
}
return 0;
}
The program compiles without any errors or warnings, but the array isn't being passed to erts
. When I run it, it doesn't print anything, instead it takes a couple seconds before exiting with a value of 3221225477. I want to pass the array from questions()
to erts
in main but I'm not sure how.