I have this problem when I run the program below. Everything compiles just fine, but when I run it and input something, i get the Segmentation fault message. Its not a full code just a part of it which is supposed to write some strings(adresses) from an input file to an array of strings then find possible matches for the searched string(input as an argument) in the array.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char *entry1 = argv[1], *adress[100], *possibleAdress[100], c;
int i,j,k,possible = 0;
while(c = getchar()!=EOF) //write addresses to array
{
while(c = getchar()!=13)
{
adress[i][j] = c;
j++;
}
i++;
}
i = 0;
while(adress[i]!=0) //find adresses matching with search enrty
{
j = 0;
while(adress[i][j]!=0)
{
while(entry1[j]==adress[i][j])
j++;
if(j==strlen(entry1)) //check if the whole search entry is matching
{
possibleAdress[k] = adress[i];
k++;
}
i++;
}
}
return 0;
}