Populating an Array of Struct

  • Thread starter Michael R. Copeland
  • Start date
M

Michael R. Copeland

I can't to get the syntax of array declarations to work. The "TCX"
declaration compiles without error, but the data does not get into the
array. The "tcx" declaration produces a compile error ("error C2064:
term does not evaluate to a function") - which doesn't make sense to me.
Both situations are wrong, and I don't know what to do with either.
TIA
/*------------- code -----------------------------------------------*/
#include <stdlib.h>
#include <string.h>
struct TCD
{
char teamGender;
char teamType[24];
short teamAge;
};
TCD TCX[49] = { ('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('f',"",00)
('m',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('f',"",97)('m',"",93)('f',"",93)('m',"Military teams",94)('f',"",94)
('f',"Female teams",95)('f',"",92)('m',"Open male teams",91)
('f',"Open female teams",91)('m',"Open mixed teams",92)('m',"",90)
('f',"",90)('m',"Male teams",95)('m'," ",90)('m',"",97)('f',"",98)
('m',"",98)('m',"",99)('f',"",89)('m',"",89) };

TCD tcx[3] = { ('f', "abc", 97)('g', "def", 98)('h', "ghi", 99) };

int main()
{
return 0;
}
 
V

Victor Bazarov

Michael said:
I can't to get the syntax of array declarations to work. The "TCX"
declaration compiles without error, but the data does not get into the
array. The "tcx" declaration produces a compile error ("error C2064:
term does not evaluate to a function") - which doesn't make sense to
me. Both situations are wrong, and I don't know what to do with
either.

Replace all parentheses in the initialisers with curly braces. Let's
hope your text editor can do that. And put commas between the closing
and the next opening curly braces:

TCD TCX[] = {
{'u',"",00},{'u',"",00},{ ...
TIA
/*------------- code -----------------------------------------------*/
#include <stdlib.h>
#include <string.h>
struct TCD
{
char teamGender;
char teamType[24];
short teamAge;
};
TCD TCX[49] = {
('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('f',"",00)
('m',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)('u',"",00)
('f',"",97)('m',"",93)('f',"",93)('m',"Military teams",94)('f',"",94)
('f',"Female teams",95)('f',"",92)('m',"Open male teams",91)
('f',"Open female teams",91)('m',"Open mixed teams",92)('m',"",90)
('f',"",90)('m',"Male teams",95)('m'," ",90)('m',"",97)('f',"",98)
('m',"",98)('m',"",99)('f',"",89)('m',"",89) };

TCD tcx[3] = { ('f', "abc", 97)('g', "def", 98)('h', "ghi", 99) };

int main()
{
return 0;
}

V
 
P

Phlip

Michael said:
TCD TCX[49] = { ('u',"",00)

You need = { { 'u',"",00 }, { 'u',"",00 }, ...

Search and replace ')(' for '}, {', for a quick fix.

After that, note that "" and 00 are the defaults (and that 00 is octal,
which is irrelevant here). You can get by with just { { 'u' }, { 'u' }, ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top