Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C][help request] variable with typestruct
#2
Do you mean something like this?

Code:
#include <stdio.h>
#include <stdlib.h>

typedef struct
{
     unsigned short a, b, c, d, e, f, g, h;
}est_;

est_ est[512];

int main(int argc, char**argv)
{
  est[0].a = 123;
  est[0].b = 124;
  est[0].c = 125;
  est[0].d = 126;
  est[0].e = 127;
  est[0].f = 128;
  est[0].g = 129;
  est[0].h = 130;

  fprintf(stdout, "ans->%d\n", est[0].a);
  fprintf(stdout, "ans->%d\n", est[0].b);
  fprintf(stdout, "ans->%d\n", est[0].c);
  fprintf(stdout, "ans->%d\n", est[0].d);
  fprintf(stdout, "ans->%d\n", est[0].e);
  fprintf(stdout, "ans->%d\n", est[0].f);
  fprintf(stdout, "ans->%d\n", est[0].g);
  fprintf(stdout, "ans->%d\n", est[0].h);
  exit(EXIT_SUCCESS);
}

The other thing your trying to do is illegal.
var='a';
est[1].[var]=0;
The value 'a' has no meaning in address resolution. Its just the value 0x61 hex...G4143

If this is where your C++ tutorial or book is taking you then get rid of them because your way off with this one...
Slackware 13/ArchLinux - C/Assem/Python
Reply


Messages In This Thread
RE: [C][help request] variable with typestruct - by g4143 - 10-08-2009, 06:34 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)