I am trying to make function that fills array of strings with lines from file, but the compiler (GCC) still giving me a warning. Than if I try to run compiled app, it gives me "Segmentation fault" error
Source code:
main
#include <stdio.h>
#include "getAdresses.h"
int main(int argc, char **argv){
char adresses[1024][128];
getAdresses(adresses);
printf("%s", adresses[1]);
}
getAdresses
include <stdio.h>
int getAdresses(char **adresses){
FILE *fr;
fr = fopen("adresses", "r");
int i = 0;
while(adresses[i-1][0] != EOF){
fscanf(fr, "%s\n", &adresses[i]);
i++;
}
}
It's giving me this error:
main.c: In function ‘main’:
main.c:9:2: warning: passing argument 1 of ‘getAdresses’ from incompatible pointer type [enabled by default]
In file included from main.c:3:0:
getAdresses.h:1:5: note: expected ‘char **’ but argument is of type ‘char (*)[128]’