0

Hi
I am just in the process of learning C++. I was trying this program that displays arrays using a pointer.

#include<iostream.h>
int getarray();
int display(int*,int,int);
int a[4][4];
main(void){
//getarray();
int a[4][4]={1,2,3,4,5,6,7,8,9,0,1,2};
display(a,4,4);
cin.get();
}

int getarray(){
int a[4][4]={1,2,3,4,5,6,7,8,9,0,1,2};
}

void display(int (*a)[4],int rows,int column){
int p;
for (int i=0;i<rows;i++){
p=a+i;
for(int j=0;j<column;j++){
cout<<"  "<<*(a+j)<<"  ";
}
cout<<'\n';
}
cout<<'\n';
}

But then I always get a error that there is a "invalid conversion from int(*)[4] to int".

What does it mean, How do i solve it? Do put your response

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Salem
0

Also do tel me what is the process of creating functions in seperate files and referencing them under a single file.

I use a dev-C++ for my coding

0

1. Read all the copious introductions on how to use [code]
[/code] tags.

2. Make these the same
int display(int*,int,int);
void display(int (*a)[4],int rows,int column)

3. #include<iostream.h>
Does your compiler warn about deprecated headers?

0

1. have i made a mistake in declaring some tags?

2.How do I get to make the two same?

3. No there is no warning like that.

Thanks for your time

0

> 1. have i made a mistake in declaring some tags?
Isn't that what I just said?

> 2.How do I get to make the two same?
ctrl-c and ctrl-v ?

> 3. No there is no warning like that.
Did you get the latest version?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.