#include<stdio.h>
int main(){
char *msg[10];
scanf("%s", msg[0]);
scanf("%s", msg[1]);
scanf("%s", msg[2]);
scanf("%s", msg[3]);
}
When I try to run this code, it gives errors. Am I doing something wrong? I'm still a beginner in C language.
Here
msgis array of 10 char pointer and they are not initialized. If you want to store something into them, first allocate the memory dynamically.print it & do the operation as you wanted
Once work is done, free the dynamically allocated memory using
free()for each char pointer asI hope it helps.