Trouble Accesing Array members
Sorry for the many questions but am about to go nuts here. This worked in another project of mine but now it just keeps crashing my program.
Here is the troubled code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,m,p, k;
char* *setArray;
char newsetArray[10];
for(p=0; p<10; p++){
newsetArray[p] = 0;
}
setArray = calloc(3, sizeof(char*));
for(i=0; i<3; i++){
setArray[i]=calloc(200, sizeof(char));
printf("\nType your set:\n");
gets(setArray[i]);
}
compare(setArray[0],setArray[1]); <---------------Look here
return 0;
}
int compare(char *c1, char *c2)
{
printf(c1[0]); <------------------- and here
return 0;
}
The trouble spot is in the red. Basically the function gets passed a string that's also stored in an array and then the function breaks down the string. (am about to compare the values). Now this worked before but now it keeps crashing. Now I tested it with this:
printf(c1);
And that confirm that the string is passed since it prints out everything. But I want to split up the string and don't understand why its causing these problems.