c - fscanf segfault reading into an array -


why fscanf in code giving me segfault?

int main(int argc, char *argv[]) {   file *file = fopen(argv[1], "r");   int n = atoi(argv[2]);    char *words[n]; int i=0;   while ((fscanf(file, "%s ", &words[i])) != eof) i++; } 

because didn't allocate memory words[i]. pointers point random memory addresses.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -