![]() |
|
#1
|
||||
|
||||
passing tables as arguments to functions.Again, the assmbler project ...
I have these tables defined : CPP / C++ / C Code:
CPP / C++ / C Code:
Now, in my main function, I add data and instructions into the tables. the data and instructions are added o.k. (I can print the data from the main function). Now, I pass the tables to another function to create output files. This function is defined as : CPP / C++ / C Code:
and I call to it from main like this : CPP / C++ / C Code:
Now, after debugging I can tell that the data and instruction tables are not passed o.k. since these calls : CPP / C++ / C Code:
generate access violation ... What am I doing wrong ? How should I pass the tables correctly ? Best regards, Kobi. |
|
#2
|
|||
|
|||
|
CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
Quote:
The memory allocation is done within the function : CPP / C++ / C Code:
And : CPP / C++ / C Code:
and the call to these functions (an example from the code): CPP / C++ / C Code:
|
|
#4
|
||||
|
||||
The question in a different form.Why does my_table doesn't hold the changes ?
CPP / C++ / C Code:
The function add_data if defined : CPP / C++ / C Code:
|
|
#5
|
|||
|
|||
|
Quote:
You should pass a pointer to the pointer variable my_table in function add_numbers and not the actual pointer. CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#6
|
|||
|
|||
|
First, with regard to your use of realloc, is this item to note.
It might be easier if you could post a minimal subset of your code, and any necessary input file, that demonstrates the problem. If I were to go about cobbling together something, it might not be what you actually have. |
|
#7
|
||||
|
||||
I Understand.Quote:
Thanks. I'll be brief next time. |
|
#8
|
||||
|
||||
Thanks for the example.Quote:
I thought that was the answer but I still don't understand why... And I never do things I don't understand Can you please explain why passing a plain pointer to a variable isn't "good enough" ? |
|
#9
|
|||
|
|||
|
Quote:
[edit]Very much like this CPP / C++ / C Code:
[edit2] CPP / C++ / C Code:
|
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing multiple objects in functions | crystalattice | C++ Forum | 3 | 08-Oct-2004 08:18 |
| passing functions | oshiotse | C++ Forum | 0 | 27-May-2004 14:51 |
| Help on passing in arrays in functions? | nusstu | C Programming Language | 10 | 02-Apr-2004 10:42 |
| Passing Pointers To Pointers in Functions | elumira | C Programming Language | 8 | 05-Mar-2004 21:23 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The