Wednesday, May 6, 2009

cygwin shell syntax error near unexpected token

This is a common error and the reason is your are using Windows to create the file. Thus the line break is \r\n rather than \n.

All you need to do is change the format using a system command:

dos2unix filename_here


Anonymous said...

Don't know why but it works now. Thnaks a lot from Spain.
p.d. I have to write it every time when im compiling a program?

Anonymous said...

I am getting a syntax error near unexpected token '$'\r''

And I do not see the error can you help me out.


int iNumber = 30;
int *iPtr = NULL;

iPtr = &iNumber;

printf("\n*iPtr = %p\n", iPtr, &iNumber);
printf("\nThe value is: %d\n", iPtr, iNumber);

Anonymous said...

I figured it out.

Muffin said...

I am stumped I have errors on line 12,13,17,18,19. Could you give me a clue at what I have done wrong?


int cPtr(char []);
int cCharacter(char []);


const int iNumber = 30;
int *iPtr = NULL;
const int fFloat = 3.123456;
int *fNumber = 0.0;
const char *cPtr[] = 'A';

*iPtr = &iNumber;
*fFloat = &fNumber;
*cPtr = &cCharacter;

printf("\nThe Value of iNumber: %d\n", iPtr, &iNumber);
printf("\nThe Address of *iPtr = %p\n", iPtr, &iNumber);

printf("\nThe Value of fNumber: %d\n", fFloat, &fNumber);
printf("\nThe Address of *fFloat = %p\n", fFloat, &fNumber);

printf("\nThe Value of cCharacter: %c\n", cPtr, &cCharacter);
printf("\nThe Address of cPtr = %p\n", cPtr, &cCharacter);