473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

invalid use of array with unspecified bounds

Hi

I have no idea what the problem is?

It is giving me this error:
invalid use of array with unspecified bounds

How can I fix it.

Thanks.

The program - in Dev-Cpp

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define N 3
  5.  
  6. void print_matrix( int a[][]);
  7.  
  8. int main()
  9. {
  10.     int a[N][N] = { { 1, 2}, { 3, 4} }, 
  11.         b[N][N] = { { 5, 6}, { 7, 8} }, 
  12.         c[N][N];
  13.     int i, j, k;
  14.  
  15.     printf("Matrix \n");
  16.  
  17.     print_matrix( a);
  18.  
  19.     for( i = 0; i < N; i++)
  20.     {
  21.          for( j = 0; j < N; j++)
  22.          {
  23.               c[i][j] = a[i][j] * b[j][i];     
  24.          }     
  25.     }
  26.  
  27.     print_matrix( a);
  28.  
  29.     printf("\n");
  30.     system("pause");
  31.     return 0;
  32. }
  33.  
  34. void print_matrix( int a[][])
  35. {
  36.      int i, j;
  37.  
  38.      for( i = 0; i < N; i++)
  39.      {
  40.            for( j = 0; j < N; j++)
  41.            {
  42.                 printf(" %d", a[i][j]);     /* Here is the Problem - in this line */
  43.            }     
  44.      }
  45.      printf("\n");
  46. }
May 17 '10 #1
1 6277
Banfa
9,065 Expert Mod 8TB
if you declare as array as

int array[D1][D2];

then when you access a member array[x][y] the compiler performs this calculation to find the correct address

array + (x * D2) + y

In your function you have not declared an array at all you have declared

void print_matrix( int a[][])

which gives a the type int **. The are no dimensions and there is no value D2 for the compiler to use in the address calculation.

You have a couple of options, you could declare the parameter of print_matrix differently or you can do the address calculation yourself manually since you know that D2 actually equals N.

You may find reading this helpful
May 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dbuser | last post by:
Dear experts: Hope you can point my error here. This function of mine receives an array of length 32 and then the for loop adds some scrambled characters at patterns. I think, I can not read the...
14
by: Christopher Benson-Manica | last post by:
From FAQ 6.13: int arr; int (*a)=arr; /* legal, but useless */ printf( "%d\n", a ); /* error, bounds of a unspecified */ Are there non-contrived situations where an array of unspecified...
50
by: jacob navia | last post by:
As everybody knows, the C language lacks a way of specifying bounds checked arrays. This situation is intolerable for people that know that errors are easy to do, and putting today's powerful...
22
by: Neo | last post by:
Hi Folks, #include<stdio.h> int main() { int (*p); int arr; int i;
11
by: miketigerwoods | last post by:
I'm having problems where I need to parse a command line, and place each token from strtok() into an array. I've read here: http://www.phim.unibe.ch/comp_doc/c_manual/C/CONCEPT/arrays.html (at...
7
by: Andrew Joros (ezze16 | last post by:
I have no idea what the problem is... It is giving me this error: invalid use of array with unspecified bounds How can I fix it. Thanks. #include <stdio.h> // Prototype
6
by: ad | last post by:
I have a huge sting array, there are about 1000 element in it. How can I divide the huge array into small ones, and there are one 10 elements in a small one array?
6
by: Alan Roberts | last post by:
In VB6 I had a function that tested whether an array had any items in it as follows Public Function ArrayIsEmpty(TestVar As Variant) As Boolean On Error Resume Next Dim i As Long i =...
2
by: Aleramo | last post by:
I have this function: double calcolo_errore (gsl_vector_complex *w_k, int elementi,gsl_vector_complex *steering_vector_c_t, int teta_l, int teta_r, int fi_r, int fi_l, int counter, double...
6
by: Arnshea | last post by:
(apologies for the crosspost) I'm working with an MFC based COM object. From C# I'd like to be able to call a method on the COM object that takes a string array and modifies the contents. Is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.