hi,
i wanna use an array in my main for declaring and fill the array.
but i wanna use in my function the array to determine who is oldest person
but when i call my function in main i get error :
parse error before ']' token
here is code:
#include <stdio.h>
int oldest(int array [2][3])
{
int i,j,pers;
for(j=0;j<3;j++){
if (array[0][j]==array[1][j])
if (j==2)
pers=0;
else if(array[0][j]>array[1][j]){
pers=1;
break;
}else{
pers=2;
break;
}
}
}
main()
{
int array[2][3],i,j;
for(i=0;i<2;i++){
for(j=0;j<3;j++){
printf("year of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
printf("month of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
printf("day of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
}
printf("\n"
}
printf("Oldest person: %d",oldest(array[][])); /*->parse error before ']' token*/
}
i wanna use an array in my main for declaring and fill the array.
but i wanna use in my function the array to determine who is oldest person
but when i call my function in main i get error :
parse error before ']' token
here is code:
#include <stdio.h>
int oldest(int array [2][3])
{
int i,j,pers;
for(j=0;j<3;j++){
if (array[0][j]==array[1][j])
if (j==2)
pers=0;
else if(array[0][j]>array[1][j]){
pers=1;
break;
}else{
pers=2;
break;
}
}
}
main()
{
int array[2][3],i,j;
for(i=0;i<2;i++){
for(j=0;j<3;j++){
printf("year of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
printf("month of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
printf("day of birth - persoon %d: ",i+1);
scanf("%d",&array[j]);
}
printf("\n"
}
printf("Oldest person: %d",oldest(array[][])); /*->parse error before ']' token*/
}