Hi, I am working on this code:

#include <iostream>
using namespace std;

send(to, from, count)
{
         register int *to, *from;
         register int count;
         {
                 register n=(count+7)/8;
                 switch(count%8){
                 case 0: do{     *to++ = *from++;
                 case 7:         *to++ = *from++;
                 case 6:         *to++ = *from++;
                 case 5:         *to++ = *from++;
                 case 4:         *to++ = *from++;
                 case 3:         *to++ = *from++;
                 case 2:         *to++ = *from++;
                 case 1:         *to++ = *from++;
                         }while(--n>0);
                 }
         }
}

int main()
{
	int i;
	int a[5]={1,2,3,4,5};
	int b[]={0,0,0,0,0};

	/*output each a[i] and b[i] in decimal separated by a Tab on one line*/
	for(i=0; i<5; i++)
		printf("%d\t%d\n", a[i], b[i]);

	printf("----------------\n");

	send(b, a, 5);

	for(i=0; i<5; i++)
		printf("%d\t%d\n", a[i], b[i]);
}

and am getting the following error:

expected constructor, destructor, or type conversion before '(' token

I've tried using different types but it only gives me more errors. Can anyone help me fix this?

prepend void before send(...), thus making send a function, because the compiler is thinking its a constructor of some sort.

Using void returns these errors:

5: error: variable or field 'send' declared void
5: error: 'to' was not declared in this scope
5: error: 'from' was not declared in this scope

You need to define it as a function :

void send(int *to,int *from, int count)
{
         {
                 register n=(count+7)/8;
                 switch(count%8){
                 case 0: do{     *to++ = *from++;
                 case 7:         *to++ = *from++;
                 case 6:         *to++ = *from++;
                 case 5:         *to++ = *from++;
                 case 4:         *to++ = *from++;
                 case 3:         *to++ = *from++;
                 case 2:         *to++ = *from++;
                 case 1:         *to++ = *from++;
                         }while(--n>0);
                 }
         }
}

I had already tried this but then forgot to remove lines six and seven from my code. All I added to your version was the type "int" to register n. Thank you very much firstPerson.

This article has been dead for over six months. Start a new discussion instead.