Structs

From: MatthewL (matthewl_at_btinternet.com)
Date: 12/31/03


Date: Wed, 31 Dec 2003 15:04:39 +0000 (UTC)

Hi,
I'm having a few problems using a strucutre.

struct iCoords

{

int X;

int Y;

};

iCoords myCoords[5] = {-1, -1};

myCoords[0].X = 325;

myCoords[0].Y = 240;

myCoords[1] = {225, 340};

I can initialize the struct fine with the first line of code, but there
after it complains.

For the second and third lines where I try to initialize the two X and Y the
compiler tells me I'm missing a ';' before '.'.

One the fouth line the compiler tells me I have too many initializers.

Can anyone explain what I'm doing wrong here please? :(



Relevant Pages

  • Re: assigment statement can use an expression when declaring a variable?
    ... int main ... initialize, you can use an expression on the right hand side of the ... But the declarations are not statements, ... if you're using the popular gcc compiler ...
    (comp.lang.c)
  • Re: Error when assigning char* to structure member
    ... 14 int main ... You can only initialize global variables with values that are known at ... this case is not an lvalue and the compiler is ... To highlight the difference try to imagine how "STRING" and ptr are ...
    (comp.lang.c)
  • Re: copy constructors and printf
    ... > conversion to an unknown type. ... Normally, you initialize parameters with ... void foo(int parameter); ... Therefore the compiler has a very short and very fixed list of conversions. ...
    (comp.lang.cpp)
  • Weird pointer error
    ... int main{ ... I know I can initialize on definition. ... assign values to pointers when I don't initialize them. ... So the compiler allocates memory ...
    (comp.lang.cpp)
  • assigment statement can use an expression when declaring a variable?
    ... int main ... float bread_price = 0.99; ... initialize, you can use an expression on the right hand side of the ... but I just have a good compiler that ...
    (comp.lang.c)