Hail! Wise and Glorious Gods of C Coding.
I have written a little function to search an array and it is cousing the program to hang after I enter the search criteria,It should should the array for a match and then return the whole string it was found in.
There is no error msg, and it compiles, I am using Dev-C. A pop-up juct comes and say's "the Program has stopped working, Windows is checking for a solution"
Would someone take a look and tell me where I have gone wrong and then give me a push in the right direction.
MyFunction
char find() {
int ctr;
char search[50];
int found;
printf("search for");
fflush(stdin);
scanf("%s",&search);
for(ctr=0; ctr<50;ctr++);
{
if(search[ctr] == array[8][ctr])
{
found=1;
}
}
printf("%s",found);
printf("\n\n%s",array[8][ctr]);
if(found){
for(ctr=0; ctr<50;ctr++) {
printf("%s",array[8][ctr]);
}
}
}
MyData
in
char array[8][50] /*I believe thats whats in there, when I print printf("\n\n%s",array[n]); from my main this is what I get */
Lord Dunsmore?is married to?Lady Emily
Miss Secrest?called?the Inspector
The gardener?is married to?the maid
Poison?can be procured by?a blood relative
Mr. Mason?visited?at 3:00 P.M.