Hello. I'm new here. Anyways, I'm trying to write a program where a user inputs strings into an array of character pointers using scanf(). However, everytime I run this program, I get segmentation faults. I don't know what is wrong with it. I've tried debugging it, but I couldn't pinpoint why scanf() is failing.
Here is my code:
Code:
#include "stdio.h"
#define SIZE 5
void input(char *string, char *string2);
int main(void)
{
char *string[SIZE], *string2[SIZE];
int counter;
for(counter = 0; counter <= SIZE - 1; counter++)
input(string[counter], string2[counter]);
putchar('\n');
for(counter = 0; counter <= SIZE - 1; counter++)
printf("%s %s\n", string[counter], string2[counter]);
return 0;
}
void input(char *string, char *string2)
{
printf("Enter string 1: ");
scanf("%s", string);
printf("Enter string 2: ");
scanf("%s", string2);
}
Thanks in advance.