--- In c-prog@yahoogroups.com, "qzqiang917" <qzqiang...@...> wrote:
>
>       for(i = 0; i < length; i++)
>               k[i] = scanf("%d");

If you are using Linux and compile this using gcc -Wall, you get a warning for 
the scanf():

  warning: too few arguments for format

Presumably it should be:

    scanf("%d", &k[i]);

(it would be a good idea to add some error checking as well)

However I think there is still at least one bug - I ran the corrected code and 
it crashed. Have you tried using a debugger? If you are using linux, compile 
using:

> gcc -g -Wall prog.c

(the -g generates information for the debugger) then run it using gdb:

> gdb a.out
(gdb) run

which at least will tell you where it's crashing. Plenty of online help eg.
http://www.cs.princeton.edu/~benjasik/gdb/gdbtut.html

You might also have a graphic front end for gdb such as Kdbg installed on your 
system.

John

Reply via email to