I have this code:

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

I want to know if there is a way to access to a variable of est by this kind of thing:

var='a';
est[1].[var]=0;

Yes, it doesnt work but, there is a way to do such a thing?

Greetings!

That could be close to making sense to me, but not quite. Are you trying to do something more like this?

est[var].a=0;

Or perhaps you could elaborate more about what you're trying to do.

Not with C or C++.

Ok the question is that i need it inside a function . . .

int f_mov(char uno, char dos, int op, int pid)
{
	if(oneop(op) || op == O_NULL)
		return ERROR;
        /*Here, i want to do something like:
        est[pid].[uno]=est[pid].[dos];
        or something to avoid a lot of comparisions*/
	return OK;
}

I was thinking of the "frequency counter with an array" thing which almost seemed similar:

++freq['a'];

But with uno, dos, a, b, c, d, e, f, g, h -- I can't discern any sort of relationship.

Well, i think i will use a two dimension array :)

Thanks anyway!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.