magician
Newbie level 3
three dimension array turbo c
hi friends
a section of my program ( written for mega16 ) is like this:
in fact, i want to pass array "a.mark" to "func()" and fill this array by character 'a' ( just for example! ) in the function. I tested this program in TurboC and it worked accurately. then I ported the same program to codevision. but it didn't work propely.
I know that i should declare the function like this:
void func(char array[][10][5]);
in other words, an array wothout first index as a parameter. But codevision gives an error and rejects this, and then i have forced to declare it as follows:
void func(char array[2][10][5]);
now the next problem happens! there isn't any error, but it dosn't work properly also! when the index "i" gets the value "2" ( and larger than 2 ), array "a.mark" dosn't recieve character 'a'.
so where is the problem? is my declaration wrong?
hi friends
a section of my program ( written for mega16 ) is like this:
Code:
#include <stdio.h>
struct test {
char name[30];
char mark[2][10][5];
}a,b,c;
int i,j;
void func(char array[][10][5]);
void func(char array[][10][5])
{
for(i=0;i<10;i++)
{
for(j=0;j<5;j++)
array[0][i][j]='a';
}
}
int main ()
{
clrscr();
func(b.mark);
for(i=0;i<10;i++)
{
printf("\n");
for(j=0;j<5;j++)
printf("%c",b.mark[0][i][j]);
}
}
in fact, i want to pass array "a.mark" to "func()" and fill this array by character 'a' ( just for example! ) in the function. I tested this program in TurboC and it worked accurately. then I ported the same program to codevision. but it didn't work propely.
I know that i should declare the function like this:
void func(char array[][10][5]);
in other words, an array wothout first index as a parameter. But codevision gives an error and rejects this, and then i have forced to declare it as follows:
void func(char array[2][10][5]);
now the next problem happens! there isn't any error, but it dosn't work properly also! when the index "i" gets the value "2" ( and larger than 2 ), array "a.mark" dosn't recieve character 'a'.
so where is the problem? is my declaration wrong?