User forums > Help
compilation error
(1/1)
calinraducalin:
I am running Code::Blocks 10.05 on Mac OS X 10.6.8
void swap(int& a, int& b)
{
int aux;
printf("\nValues at entry: a=%d b=%d\n", a, b); aux=a; a=b; b=aux;
printf("\nValues at exit: a=%d b=%d\n", a, b);
}
void main()
{
int a, b;
a=2; b=3;
printf("\nIn the main function, prior to invoking swap: a=%d b=%d\n", a, b);
swap(a, b);
printf("\nIn the main function, after the return from swap: a=%d b=%d\n", a, b);
}
in compilation, it appears the following error:
error expected : "," , "," or ")" before token "&"
I have coppied the source from a book.
zabzonk:
You are trying to compile C++ as C code, probably because you have given the file a .c extension rather than a .cpp one. This is really not a Code::Blocks issue, and you should ask this and similar questions regarding C++ at sites like http://www.reddit.com/r/learnprogramming
calinraducalin:
Thanks! your suggestion worked for me!
Navigation
[0] Message Index
Go to full version