I just copied and pasted all the things that has been happening from the shell here:
lin309-05:~/workspace/acm$ gdb a.out
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /.../workspace/acm/a.out...done.
(gdb) break main
Breakpoint 1 at 0x400f8f: file 156.c, line 164.
(gdb) r
Starting program: /.../workspace/acm/a.out
Breakpoint 1, main () at 156.c:164
164 freopen("input.txt", "r", stdin);
(gdb) n
168 scanf(" %s", dictionary[i]);
(gdb) n
[B]Program received signal SIGSEGV, Segmentation fault.
_IO_vfscanf_internal (s=0x7ffff76296a0, format=<value optimized out>, argptr=0x6c, errp=<value optimized out>) at vfscanf.c:1053
1053 vfscanf.c: No such file or directory.
in vfscanf.c[/B]
(gdb) q
A debugging session is active.
Inferior 1 [process 4610] will be killed.
Quit anyway? (y or n) y
lin309-05:~/workspace/acm$ ls input.txt
input.txt
The code is below:
int main()
{
char dictionary[DIM_DICT][500];
sign signature[DIM_DICT];
int n;
int i;
int j;
int k;
int count;
char output[DIM_DICT][500];
freopen("input.txt", "r", stdin);
while (1)
{
scanf(" %s", dictionary[i]);
if (!strcmp(dictionary[i], "#"))
{
break;
}
gen_signature(signature, dictionary, i);
n++;
i++;
}
...
}
This doesn't make sense. I used gdb just yesterday. And the problemetic line is
scanf(" %s", dictionary);
dictionary is an array of strings. So what's wrong?