I want to fill a structure and then print it.
How to print the values of the structue?
The structure is:
#define UINT32 unsigned int
#define INT32 int
#define UCHAR unsigned char
typedef struct CheckSumPair
{
UINT32 weakcs; // The weak, rolling Adler32 checksum.
UCHAR StrongCS[10];
};
I have dynamically allocated memory to it as folows.
CheckSumPair* CSPair = (CheckSumPair*)malloc(sizeof(CheckSumPair)*10);
for(int x = 0;x < 10;x++)
{
CSPair->weakcs = (UINT32)x+1;
strncpy((char*)CSPair->StrongCS,(char*)"XYZ",10);
strncpy((char*)CSPair->StrongCSString,(char*)"CEDVCD",10*2+1);
}
Now print the values
for(int x = 0;x < 10;x++)
printf("%d %s %s\n\n",CSPair[x]->.weakcs,CSPair[x]->StrongCS,CSPair[x]->StrongCSString);
While printing the values I get the following error:
error C2232: '->CheckSumPair::StrongCS' : left operand has 'struct' type, use '.'
error C2819: type 'CheckSumPair' does not have an overloaded member 'operator ->'
see declaration of 'CheckSumPair'
How to resove the issue?