This is driving me nuts.

This is a discussion on This is driving me nuts. within the C Programming forums, part of the General Programming Boards category; OK. There are at least two errors in the attached code (the associated .h file has a few in too ...

  1. #1
    Not bad at Crack Attack!
    Join Date
    Aug 2003
    Posts
    45

    This is driving me nuts.

    OK. There are at least two errors in the attached code (the associated .h file has a few in too I am sure). I get the second when I eliminate most of the references to the array "nodes" which seems to be perfectly well defined (I can loop through it and printf its elements on screen) but any attempt to access its contents in the following manner:
    Code:
    c[p]=sumarray(adjacency[nodes[p]],N);
    results in a bus error.

    I'm using gcc on a unix system and I'm completely exhausted from trying to work out what's wrong.

    PS: please excuse all the diagnostic printf statements in the code!

  2. #2
    Not bad at Crack Attack!
    Join Date
    Aug 2003
    Posts
    45

    File

    Sorry!
    Attached Files Attached Files

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Code:
      int *oldtempnames, *newtempnames, *nodes, *c;
       /* ... */
       int *nodes=calloc(i,sizeof(int));
    Can you tell me which version of nodes gets allocated memory, and which one is in scope when you call sumarray?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Not bad at Crack Attack!
    Join Date
    Aug 2003
    Posts
    45

    Thanks!

    Hmmm! A schoolboy error! Now to fix that error in the deletethings subfunction!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. This is driving me nuts...
    By jesin in forum C Programming
    Replies: 5
    Last Post: 11-22-2005, 04:17 AM
  3. i can't fix it! its driving me nuts
    By faxtoaster in forum C Programming
    Replies: 2
    Last Post: 07-10-2003, 05:46 PM
  4. This compiler is driving me nuts
    By martin_00 in forum C Programming
    Replies: 32
    Last Post: 12-31-2002, 02:25 PM
  5. driving me nuts
    By boontune in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2002, 04:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21