need help with problem

Hi,

I have been trying to compile this code with no avail.
I am using windows XP and DEV C++. It's a long code but I have posted the first part of it below:


# include <iostream>
# include <cmath>
# include <fstream>

using namespace std;


struct geometricalshapes { // subroutine for assigning values to the particle geometrical shapes
float side1, side2, side3, side4, side5;
float angle1, angle2, angle3, angle4, angle5;
float height, base, centroidx, centroidy, momentofinertiax, momentofinertiay, area;

};

float ddamping_coefficient, dk;
double dstiffness_coefficient;
double dtime_increment;
float dmass;
float ii; // mass moment of inertia
float dresult;

int main ()

{
geometricalshapes righttriangle; //the particle
righttriangle.side1 = 4.243;
righttriangle.side2 = 3;
righttriangle.side3 = 3;
righttriangle.angle1 = 45;
righttriangle.angle2 = 45;
righttriangle.angle3 = 90;
righttriangle.height = 2.12;
righttriangle.base = 4.243;
righttriangle.centroidx = 0;
righttriangle.centroidy = 0.707;
righttriangle.momentofinertiax = 1.123;
righttriangle.momentofinertiay = 3.374;
righttriangle.area = 4.498;

}}

The error statement is the following:

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\my-project.cpp" -o "C:\Dev-Cpp\my-project.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Dev-Cpp\my-project.cpp:42: error: expected declaration before '}' token

Execution terminated

This error statement applies to the last line posted (with double curly brackets) I have tried removing one or both brackets but the errors only increased.

I appreciate any help...

When I chop off that second final } it compiles without error. Whatever the problem is, it's not in this code.
Last edited on
You open main with one curly brace...and close it with two!? You only need to close it with one curly brace. It should have compiled when you removed the extra one...
If I don't remove the one extra curly brace I get one error; the one I posted above. If I do remove it, however, I get 9 errors (code below the double curly braces). Weird...I don't know what's wrong..
These are the errors I get when I remove the one extra curly brace:

:\Dev-Cpp\my-project.cpp:44: error: expected unqualified-id before '{' token
C:\Dev-Cpp\my-project.cpp:44: error: expected `,' or `;' before '{' token
C:\Dev-Cpp\my-project.cpp:59: error: expected unqualified-id before '{' token
C:\Dev-Cpp\my-project.cpp:59: error: expected `,' or `;' before '{' token
C:\Dev-Cpp\my-project.cpp:103: error: expected unqualified-id before '{' token
C:\Dev-Cpp\my-project.cpp:103: error: expected `,' or `;' before '{' token

C:\Dev-Cpp\my-project.cpp:122: error: expected unqualified-id before '{' token

C:\Dev-Cpp\my-project.cpp:122: error: expected `,' or `;' before '{' token
C:\Dev-Cpp\my-project.cpp:1709: error: expected declaration before '}' token

Execution terminated
What...you have code below main and you did not post it? All those errors are on lines you have not whown us. The reason the }} gives one error is because it stops trying to compile after that (hence the 'Execution terminated'). After you fix that error, it continues to compile and you see a load more errors.
Last edited on
As mentioned in my first post it is a long code and could not possibly post it here...I did post the part that had the problem..and it still exists.
The problem is not in what you have shown us. The problem is in the code you have not shown us.

The line number indicates how far the compiler gets before having to give up completely. Sometimes that is the line with the problem on. Sometimes not. In this case; not.
Thank you all..
Topic archived. No new replies allowed.