C Error Invalid Use Of Array With Unspecified Bounds
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up invalid use of array with unspecified bounds up vote 0 down vote favorite i had a question in my program. When I pass the 3D int array CodedGreen to the function Green_Decode_Tree. An error message"invalid use of array with unspecified bounds" displayed. What is the mistake in my program? Thanks for your help. for(i=0;i<256;i++){ for(j=0;j<256;j++){ Decode_Tree(green[0], CodedGreen,0,i,j); } } void Green_Decode_Tree(node* tree, int code[][][], int num,int row,int col) { int i; i=num; if((tree->left == NULL) && (tree->right == NULL)){ fprintf(DecodGreen,"%s\n", tree->ch); } else { if(code[row][col][num]==1){ i++; Green_Decode_Tree(tree->left,code,i,row,col); } else if (code[row][col][num]==0){ i++; Green_Decode_Tree(tree->right,code,i,row,col); } } } c share|improve this question edited Mar 18 '10 at 12:31 asked Mar 18 '10 at 12:11 user239468 552410 See this: stackoverflow.com/questions/4051/… , and in particular eskimo.com/~scs/cclass/int/sx9a.html –Laurynas Biveinis Mar 18 '10 at 12:18 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted i will reveal you a secret. 2d (and 3d) arrays are represented as liner memory arrays. when you have array NxM and access it like a[i][j] it is actually translated to a[i*M + j] as you might notice compiler must know M here to do this conversion, otherwise it will not be able to translate it. So thats what he asks. You must provide all except first sizes in array: int code[][M][N] share|improve this answer edited Mar 18 '10 at 13:55 answered Mar 18 '10 at 12:42 Andrey 45.9k674129 add a comment| up vote 4 down vote Remember that in most contexts, array expressions have their types implicitly converted ("decay") from "N-element array of T" to "pointer to T" and evaluate to the address of the first element. When you pass CodedGreen (type int [X][Y][Z]) to Green_Decode_Tree, what the function receives
Go to Page... Thread Tools Display Modes Dec 29th, 2006, 6:01 PM #1 deanosrs Programmer Join Date: Apr 2006 Location: Bristol, UK Posts: 31 Rep Power: 0 invalid use of array with unspecified bounds what does this error message mean? i've got a 3-d array that i can access fine in its source function, but when i pass the array as a parameter to another function then i can't access it - it gives me that error http://stackoverflow.com/questions/2469650/invalid-use-of-array-with-unspecified-bounds message. any ideas how i can get round it? i'm guessing it's because the 2nd function doesn't know how big the array is therefore doesn't like me accessing it... will post source code if someone needs it to work out what's going on. thanks in advance for any help. deanosrs View Public Profile Visit deanosrs's homepage! Find More Posts http://www.programmingforums.org/post121894.html by deanosrs Dec 29th, 2006, 7:40 PM #2 grumpy Programming Guru Join Date: Jun 2005 Location: Adelaide, South Australia Posts: 1,329 Rep Power: 13 You haven't given enough information. I assume you have a line of code that is triggering an error message from a compiler. I do not invite you to post your "source code", because most people interpret that to mean it is OK to several hundred lines of code that are completely irrelevant to their problem. Instead, I invite you to post a SMALL but COMPLETE code sample which EXHIBITS your problem. In your case, that SMALL but COMPLETE sample might include; 1) A declaration (but not necessarily implementation) of the function you are trying to call; 2) A main() function, complete with declaration of variables passed as arguments to your function and a line that calls the function; 3) Information about what compiler and what operating system you are working on. Sometimes problems are compiler specific, and such information will allow people to help you. 4) The actual text of the e
topic ForumsMembersHelp Files Developer Journals Gallery Calendar Downloads Resources Store Classifieds Tracker Links Home http://www.gamedev.net/topic/365269-invalid-use-of-array-with-unspecified-bounds-probably-something-obvious/ For Beginners Articles All Articles Post an Article Technical Game Programming https://www.gidforums.com/t-5549.html General Programming Graphics Programming and Theory DirectX and XNA OpenGL and Vulkan Multiplayer and Network Programming Artificial Intelligence Math and Physics Mobile Development Middleware, Libraries, and Tools Virtual and Augmented Reality Creative Game Design Music and Sound Visual Arts Business Breaking into c error the Industry Production and Management Interviews Business and Law Event Coverage Forums All Forums Technical Game Programming General Programming Graphics Programming and Theory DirectX and XNA OpenGL & Vulkan Multiplayer and Network Programming Artificial Intelligence Math and Physics Mobile & Console Development Build Systems & Source Control Middleware, Libraries, and Tools Virtual and Augmented c error invalid Reality Creative Game Design Writing For Games Music and Sound Visual Arts Gallery Business Breaking into the Industry Business & Law Production & Management Community GDNet Lounge Coding Horrors Article Writing Comments, Suggestions and Ideas Your Announcements Hobby Project Classifieds Indie Project Showcase Community Developer Journals GDNet+ Subscriptions Gallery Store Classifieds Jobs Freelancers Hobby Projects Marketplace Newsletter » Home » Forums » The Technical Side » For Beginners Chat Watched Content New Content 0 Invalid use of array with unspecified bounds (probably something obvious) Started by Craig M, Dec 20 2005 05:38 PM Old topic! Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic. You cannot reply to this topic 6 replies to this topic #1 Craig M Members -Reputation: 108 Like 0Likes Like Posted 20 December 2005 - 05:38 PM Argh.
Thread Tools Search this Thread Rate Thread #1 20-Apr-2005, 03:10 brett New Member Join Date: Apr 2005 Posts: 7 Noob question on c arrays and functions Hi, 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:
/* Deitel & Deitel 'C How to program' pgs. 221-2 */ /* passing arrays and individual array elements to functions */ #include#define SIZE 5 void modifyArray(int[], int); void modifyElement(int); /* doesn't do what you might expect */ main() { int a[SIZE] = { 0, 1, 2, 3, 4 }; int i; printf("Original values of array are : \n"); for (i=0; i "%3d", a[i]); modifyArray(a, SIZE); printf("\nModified values of array are : \n"); for (i=0; i "%3d", a[i]); printf("\nEffects of passing an array element : \n"); modifyElement(a[3]); printf("The value of a[3] is %d\n", a[3