Declaring a prototype of type "struct" - C
Posted
by Jamie Keeling
on Stack Overflow
See other posts from Stack Overflow
or by Jamie Keeling
Published on 2010-03-23T16:12:47Z
Indexed on
2010/03/23
16:23 UTC
Read the original article
Hit count: 254
I've been racking my brains on this for a while, I'm simply trying to create a method that returns a struct as I wish to return two int's.
My prototype for the method is as follows:
typedef struct RollDice();
Also the method itself:
typedef struct RollDice()
{
diceData diceRoll;
diceRoll.dice1 = 0;
diceRoll.dice2 = 0;
return diceRoll;
}
The compiler shows the error: "Syntax error: ')'"
for both the prototype and actual method.
The struct itself:
typedef struct
{
int dice1;
int dice2;
}diceData;
Is it obvious where I'm going wrong? I've tried everything I can think of.
Thanks
© Stack Overflow or respective owner