![]() |
|
#1
|
|||
|
|||
Noob question on c arrays and functionsHi,
I am teaching myself C using Deitel & Deitel and have got stuck with a problem updating arrays in a function. What I want to do is to update a 2D array but I get errors in Dev-C++ and gcc both. To demonstrate the problem, I have a 1D array of ints that I update in a function. When I try to extend this to a 2D array I get the errors "arithmetic on pointer to an incomplete type" in Dev-C++ (running in c mode) and "invalid use of array with unspecified bounds" in gcc. I assume that the problem is the way I am trying to update the array and use / misuse of pointers but I don't know what I should be doing to correct the error. I enclose the code for the single dimensioned array (that compiles and runs o.k.) and the 2D array that produces the error. Any help or pointers would much appreciated. CPP / C++ / C Code:
Thanks, Brett Last edited by LuciWiz : 20-Apr-2005 at 05:30.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#2
|
|||
|
|||
|
Hi again,
well I had checked around on the web but must have missed the bit in the C Faq, I looked again at section 6.18 in the faq and changed the function dec. to: void modifyArray(float b[][SIZE], int size) { and this now compiles and runs as expected. I guess that I need to read this again until I understand the way functions, pointers and arrays work. Any advice will be appreciated. Rgds, Brett |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reverse functions and Reverse checking functions | jenmaz | C Programming Language | 4 | 24-Nov-2004 09:48 |
| I am reviewing Arrays and need help converting some strings to arrays | jenmaz | C Programming Language | 22 | 23-Nov-2004 00:26 |
| Help on passing in arrays in functions? | nusstu | C Programming Language | 10 | 02-Apr-2004 11:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The