Delcaration syntax Error

#include <bios.h>
#include <stdio.h>
#include <conio.h>
#define SETTING (0x00 | 0x02 | 0xC0 | 0x08)
#define COM1 0

void main()
void sort(int a[], int b[], int elements)
{
int i, j, temp, temp_b;

i = 0;
while(i < (elements - 1))
{
j=i+1;
while(j < elements)
{
if(a[i] > a[j])
{
temp = a[i];
temp_b = b[i];
a[i] = a[j];
b[i] = b[j];
a[j] = temp;
b[j] = temp_b;
}
j++;
}
i++;
}




{
int average;
int rx, status;
char student[5][20]={"John", "sam", "clinton", "harry","Tom"};
int Electronic[5] = {85,71,50,89,74};
int Automation[5] = {79,85,65,77,69};
int arrange[5] = {0,1,2,3,4};
int loop;
float avg[5];
bioscom(0, SETTING, COM1);
printf("For Receivinf Only!\n\n Press <ESC> to quit\n");
while(1)
{
bioscom(1,0,COM1);
status=bioscom(3,0,COM1);
if((status & 0x100)!=0)

rx=rx & 0x7f;
if(rx==0x31)
{
printf("Received 1 display Electronics Module \n");
for(loop=0; loop < 5; loop++)
printf(" %d %s \n", Electronic[loop], student[arrange[loop]]);
sort(Electronic, arrange, 5);
printf("After the sort the array was \n");
for(loop = 0; loop < 5; loop++)
printf(" %d %s \n", Electronic[loop], student[arrange[loop]]);
getch();
}
if(rx==0x32)
{
printf("Received 2 display Automation Module\n");
for( loop = 0; loop < 5; loop++)
printf(" %d %s \n", Automation[loop], student[arrange[loop]]);
sort( Automation, arrange, 5);
printf("After the sort the array was \n");
for( loop = 0; loop < 5; loop++)
printf(" %d %s\n", Automation[loop], student[arrange[loop]]);
getch();
}
if(rx==0x33)
{
for(loop = 0; loop < 5; loop++)
average = (Automation[loop] + Electronic[loop])/2;
printf("Before the sort the array was\n");

for(loop = 0; loop < 5; loop++)
printf("%d%s\n", avg[loop], student[arrange[loop]]);
sort(average, arrange, 5);
printf("After the sort the array was \n");

for(loop = 0; loop <5; loop++)
printf("%d%s\n", average, student[arrange[loop]]);
getch();
}
}
{
rx=bioscom(2,0,COM1);
if((rx & 0xE0)!=0)
{
}
}
putch(0x0d);
putch(0x0a);
{
putch(rx);
if(kbit())
{
rx=getch();
}
if(rx==0x1b)
{
bioscom(1,rx,0);

}

}
}
}











;




I got the delaration syntax error, as above. situated at line 9
Last edited on

void main()
void sort(int a[], int b[], int elements)
{


You cannot implement functions inside of functions.
oh thx, so how can i correct it ?
Implement it outside of main

1
2
3
4
5
6
7
8
9
10
void sort (int a[], int b[], int elements)
{
    //Code here
}

int main()
{
    //Code here
    return 0;
}


Or.... forward declare and implement below main

1
2
3
4
5
6
7
8
9
10
11
12
void sort (int a[], int b[], int elements);

int main()
{
    //Code here
    return 0;
}

void sort (int a[], int b[], int elements)
{
    //Code here
}


Also please use the CODE tags.
I tried what you mention above but i still get the some error >.< What's wrong actually ?
post your edited code and maybe we can tell you bud :P
#include <bios.h>
#include <stdio.h>
#include <conio.h>
#define SETTING (0x00 | 0x02 | 0xC0 | 0x08)
#define COM1 0


void sort(int a[], int b[], int elements)

{
int i, j, temp, temp_b;

i = 0;
while(i < (elements - 1))
{
j=i+1;
while(j < elements)
{
if(a[i] > a[j])
{
temp = a[i];
temp_b = b[i];
a[i] = a[j];
b[i] = b[j];
a[j] = temp;
b[j] = temp_b;
}
j++;
}
i++;
}


int main()

{
int average;
int rx, status;
char student[5][20]={"John", "sam", "clinton", "harry","Tom"};
int Electronic[5] = {85,71,50,89,74};
int Automation[5] = {79,85,65,77,69};
int arrange[5] = {0,1,2,3,4};
int loop;
float avg[5];
bioscom(0, SETTING, COM1);
printf("For Receivinf Only!\n\n Press <ESC> to quit\n");
while(1)
{
bioscom(1,0,COM1);
status=bioscom(3,0,COM1);
if((status & 0x100)!=0)

rx=rx & 0x7f;
if(rx==0x31)
{
printf("Received 1 display Electronics Module \n");
for(loop=0; loop < 5; loop++)
printf(" %d %s \n", Electronic[loop], student[arrange[loop]]);
sort(Electronic, arrange, 5);
printf("After the sort the array was \n");
for(loop = 0; loop < 5; loop++)
printf(" %d %s \n", Electronic[loop], student[arrange[loop]]);
getch();
}
if(rx==0x32)
{
printf("Received 2 display Automation Module\n");
for( loop = 0; loop < 5; loop++)
printf(" %d %s \n", Automation[loop], student[arrange[loop]]);
sort( Automation, arrange, 5);
printf("After the sort the array was \n");
for( loop = 0; loop < 5; loop++)
printf(" %d %s\n", Automation[loop], student[arrange[loop]]);
getch();
}
if(rx==0x33)
{
for(loop = 0; loop < 5; loop++)
average = (Automation[loop] + Electronic[loop])/2;
printf("Before the sort the array was\n");

for(loop = 0; loop < 5; loop++)
printf("%d%s\n", avg[loop], student[arrange[loop]]);
sort(average, arrange, 5);
printf("After the sort the array was \n");

for(loop = 0; loop <5; loop++)
printf("%d%s\n", average, student[arrange[loop]]);
getch();
}
}
{
rx=bioscom(2,0,COM1);
if((rx & 0xE0)!=0)
{
}
}
putch(0x0d);
putch(0x0a);
{
putch(rx);
if(kbit())
{
rx=getch();
}
if(rx==0x1b)
{
bioscom(1,rx,0);

}
return 0;
}
}
}








kk, Soo, You're still making the exact same mistake. You can't implement a function inside of a function.

You're still implementing main() inside of sort()..Also your code is very hard to read. For future reference please use proper tabbing and place your code inside the code tags. I'd like to help but I really can't read your code.. I apologize for this.
Topic archived. No new replies allowed.