Yes, Curtis is right on, fix the , to a ;, and it works perfectly.
Parse errors, for me at least, ase usually missing ; or unpaired {} or ().
This also points our the importance of looking at first errors first, the ; error tripped multiple errors, fixing the ; fixed them all. Note my compile log with the error:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\testit.cpp" -o "C:\Dev-Cpp\testit.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:/Dev-Cpp/testit.cpp: In function `int main()':
C:/Dev-Cpp/testit.cpp:11: parse error before `;' token
C:/Dev-Cpp/testit.cpp:12: `Length' undeclared (first use this function)
C:/Dev-Cpp/testit.cpp:12: (Each undeclared identifier is reported only once for
each function it appears in.)
C:/Dev-Cpp/testit.cpp:16: `USHORT' undeclared (first use this function)
C:/Dev-Cpp/testit.cpp:16: parse error before `=' token
C:/Dev-Cpp/testit.cpp:20: `Area' undeclared (first use this function)
Execution terminated
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-02-03
Ditto. The error messages contain INFORMATION -don't be scared, read them! (Although I admit, plain English is often not the compiler's strong point - but the line number will tell you where to start looking).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following code throws up parse errors, can anyone tell me why?
// Demonstration of variables
#include <iostream>
using namespace std;
#include <stdlib.h>
typedef unsigned short int USHORT; //typedef defined
int main()
{
USHORT Width = 5,
USHORT Length;
Length = 10;
//create an unsigned short and initialize with result
//of multiplying width by length
USHORT Area = Width * Length;
cout << "Width: " << Width << "\n";
cout << "Length: " << Length << endl;
cout << "Area: " << Area << endl;
system("pause");
return 0;
}
USHORT Width = 5,
You have a , instead of a ;
would test that theory, but don't have Dev re-installed yet
Curtis
P.S. Dbl clicking on the error/Warning, should highlight the conflicting line. It also tells you the line #
Yes, Curtis is right on, fix the , to a ;, and it works perfectly.
Parse errors, for me at least, ase usually missing ; or unpaired {} or ().
This also points our the importance of looking at first errors first, the ; error tripped multiple errors, fixing the ; fixed them all. Note my compile log with the error:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\testit.cpp" -o "C:\Dev-Cpp\testit.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:/Dev-Cpp/testit.cpp: In function `int main()':
C:/Dev-Cpp/testit.cpp:11: parse error before `;' token
C:/Dev-Cpp/testit.cpp:12: `Length' undeclared (first use this function)
C:/Dev-Cpp/testit.cpp:12: (Each undeclared identifier is reported only once for
each function it appears in.)
C:/Dev-Cpp/testit.cpp:16: `USHORT' undeclared (first use this function)
C:/Dev-Cpp/testit.cpp:16: parse error before `=' token
C:/Dev-Cpp/testit.cpp:20: `Area' undeclared (first use this function)
Execution terminated
Wayne
Ditto. The error messages contain INFORMATION -don't be scared, read them! (Although I admit, plain English is often not the compiler's strong point - but the line number will tell you where to start looking).
Clifford
Or, if ytou double click on the error message, it takes you to the line in question.
Note that missing ; can be tricky, the error might show up much later in the code...
Wayne
It now works fine. I just could not see that "," i must have been going code blind.
Thanks people.
np
Curtis
I *never* do anything like that!
*Lightening strikes*
Wayne