Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with passing 3D array to function in CodevisionAVR

Status
Not open for further replies.

magician

Newbie level 3
Joined
Mar 4, 2007
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
three dimension array turbo c

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? :cry:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top