>But gdb leaves a lot to be desired for when stacked up to 
the far superior VC++ debugger

*throws large pointy projectiles at you* :)
I personally like gdb. It's a bit cryptic, but it's always worked better than 
vc for me.

Thanks,
Tyler Littlefield
email: [EMAIL PROTECTED]
web: tysdomain-com
Visit for quality software and web design.
skype: st8amnd2005

  ----- Original Message ----- 
  From: Thomas Hruska 
  To: [email protected] 
  Sent: Monday, November 10, 2008 7:56 PM
  Subject: Re: [c-prog] Infinite loop


  pm rao wrote:
  > Hi All,
  > 
  > Could you please help me out in analysing this issue:
  > 
  > I really find strange behavior with the following code. If the
  > statement b is present as below, the for loop is executing infinitely.
  > But when statement b is replaced with statement a as
  > int c[31], s[31];. Then the for loop is exited after n iterations.
  > Below is my gcc version where i executed the code. Please help me out
  > in this regard.
  > 
  > int c [30], s[30]; // statement b
  > 
  > #include <stdio.h>
  > void change (int a[], int, int);
  > int main ()
  > {
  > int d[3];
  > d[0] = 1, d[1] = 10, d[2] = 25;
  > int n = 30, k = 3;
  > change (d, k, n);
  > return 1;

  return 0;

  > }
  > 
  > void change (int d[], int k, int n)
  > {
  > int c [30], s[30]; // statement b
  > c[0] = 0;
  > int p;
  > int min, i, coin = 0;
  > 
  > for (p=1; p<=n; p++)

  Appears to evaluate to: for (p = 1; p <= 30; p++)

  Can you spot the problem? Hints: Array boundaries...you are 
  overstepping them. Zero-based arrays...

  > {
  > c[p] = 0;
  > s[p] = 0;
  > printf ("\n test : %d \n", p);

  You need to find a good IDE that can interface with gdb. KDevelop has a 
  decent IDE. But gdb leaves a lot to be desired for when stacked up to 
  the far superior VC++ debugger. Using printf() is a terrible way to 
  debug when you can set a breakpoint and step through the code 
  line-by-line and look at all the values of the variables within a GUI.

  > }
  > }
  > 
  > gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.2)
  > Copyright (C) 2006 Free Software Foundation, Inc.
  > This is free software; see the source for copying conditions. There is NO
  > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  -- 
  Thomas Hruska
  CubicleSoft President
  Ph: 517-803-4197

  *NEW* MyTaskFocus 1.1
  Get on task. Stay on task.

  http://www.CubicleSoft.com/MyTaskFocus/



   

[Non-text portions of this message have been removed]

Reply via email to