?
=?ISO-8859-1?Q?Martin_J=F8rgensen?=
Hi,
I'm trying to move a matlab program into c language. For those who knows
matlab, this is the line I want to program in c:
hx(1:nx,1:ny) = 0; % nx=10, ny=10
It works on a 2-dimensional array (size is 10*10), setting all the
values inside the 10*10 matrix to zero. My C-function looks like this:
void fillinnumbers(int fillvalue, int startx, int stopx, int starty, int
stopy, int array[][])
{
for(i=startx; i<=stopx; i++)
{
for(j=starty; j<=stopy; j++)
{
array[j] = fillvalue;
}
}
}
So, taken the above example: fillvalue = 0, startx = 1, stopx = nx = 10,
starty = 1, stopy = ny = 10, array[][] is the pointer... Now, the
problem is that I'm a C newbie so I there's something wrong with the
array[][] thing, I think...
In my C-program I tried:
fillinnumbers(3, 1, nx, 1, ny, array);
I defined array as: array[nx+1][ny+1]
But using MSVS 2005, I get the following error: "error C2087: 'array' :
missing subscript" - the error points to the line containing the
function declaration: "void fillinnumbers(int fillvalue,.... etc"
And a lot of warnings: "warning C4048: different array subscripts : 'int
(*)[1]' and 'int [11][11]" in each line where I try to call my function
such as in the line containing: "fillinnumbers(3, 1, nx, 1, ny, array);"
I'm not so experienced with C programming, so any help will be greatly
appreciated...
Best regards / Med venlig hilsen
Martin Jørgensen
I'm trying to move a matlab program into c language. For those who knows
matlab, this is the line I want to program in c:
hx(1:nx,1:ny) = 0; % nx=10, ny=10
It works on a 2-dimensional array (size is 10*10), setting all the
values inside the 10*10 matrix to zero. My C-function looks like this:
void fillinnumbers(int fillvalue, int startx, int stopx, int starty, int
stopy, int array[][])
{
for(i=startx; i<=stopx; i++)
{
for(j=starty; j<=stopy; j++)
{
array[j] = fillvalue;
}
}
}
So, taken the above example: fillvalue = 0, startx = 1, stopx = nx = 10,
starty = 1, stopy = ny = 10, array[][] is the pointer... Now, the
problem is that I'm a C newbie so I there's something wrong with the
array[][] thing, I think...
In my C-program I tried:
fillinnumbers(3, 1, nx, 1, ny, array);
I defined array as: array[nx+1][ny+1]
But using MSVS 2005, I get the following error: "error C2087: 'array' :
missing subscript" - the error points to the line containing the
function declaration: "void fillinnumbers(int fillvalue,.... etc"
And a lot of warnings: "warning C4048: different array subscripts : 'int
(*)[1]' and 'int [11][11]" in each line where I try to call my function
such as in the line containing: "fillinnumbers(3, 1, nx, 1, ny, array);"
I'm not so experienced with C programming, so any help will be greatly
appreciated...
Best regards / Med venlig hilsen
Martin Jørgensen