CodeGibbon
10-04-2011, 03:39 PM
Hey i can't seem to debug this code, the compiler says syntax error before & token.... It's the first ampersand in the first function, i have underlined it.
I can't see what's wrong with this code.
There may be problems elsewhere, but i have yet to get past this first obstacle.
#include <stdio.h>
void GetData(int &a, int &b)
{
printf("Enter first number");
scanf("%d%*c", &a);
printf("Enter second number");
scanf("%d%*c", &b);
//two values out...
return;
}
int funcSwap( int &b, int &a)
{
//two values out...
return;
}
void funcPrint(int a, int b)
{
printf("First value: ", a);
printf("Second value: ", b);
return;
}
int main()
{
int a,b;
GetData(a,b);
funcSwap(a,b);
funcPrint(a,b);
return 0;
}
I can't see what's wrong with this code.
There may be problems elsewhere, but i have yet to get past this first obstacle.
#include <stdio.h>
void GetData(int &a, int &b)
{
printf("Enter first number");
scanf("%d%*c", &a);
printf("Enter second number");
scanf("%d%*c", &b);
//two values out...
return;
}
int funcSwap( int &b, int &a)
{
//two values out...
return;
}
void funcPrint(int a, int b)
{
printf("First value: ", a);
printf("Second value: ", b);
return;
}
int main()
{
int a,b;
GetData(a,b);
funcSwap(a,b);
funcPrint(a,b);
return 0;
}