Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How do I do it in C?

Name: Anonymous 2008-05-09 4:36

Hello /prog/. Imagine I have a struct:

struct foo {
 enum entype { option1, option2 } *bar;
};

"bar" here stands for an array of enums, as you see.
Somewhere in my prog (after correctly allocating needed number of foo`s and bar`s) I have to access Nth bar in foo. I'm currently using this line:

*(enum entype*)(myfoo->bar + sizeof(enum entype)*N) = option1;

Well, it works, but I still think I'm doing it wrong. There must be an easier way, like myfoo->bar[N] or something.

Name: Anonymous 2008-05-09 4:41

Well, it works,
No it doesn't.

but I still think I'm doing it wrong.
You are.

There must be an easier way, like myfoo->bar[N] or something.
Yep.

Name: Anonymous 2008-05-09 4:47

>>2
problem solved, gentlemen.

Name: Anonymous 2008-05-09 4:52

>>2 >>3 I wish!

Here's the machine code:

/tmp/ccBC1D3W.s: Assembler messages:
/tmp/ccBC1D3W.s:191: Error: suffix or operands invalid for `call'
/tmp/ccBC1D3W.s:198: Error: suffix or operands invalid for `call'
/tmp/ccBC1D3W.s:204: Error: suffix or operands invalid for `call'

That's what happen when I try myfoo->bar[N].

Name: Anonymous 2008-05-09 4:54

>>4
/tmp/ccBC1D3W.s: Assembler messages:
Now you have 2 problems...

Name: Anonymous 2008-05-09 4:58

It compiles, but does not assemble? Truly, you now have two problems.

Name: Anonymous 2008-05-09 5:02

Your compiler and/or assembler is/are broken.  Get a new one/two.

Name: Anonymous 2008-05-09 5:15

Well, maybe it(they) is(are), GCC 3.3.4 by the way. Then I will just stick with the working solution, but first I'd ask you is it possible to write a macro that will substitute myfoo->bar[N] for that fucked line form >>1?

Name: Anonymous 2008-05-09 5:23

GCC

Now you have 3 problems.

Name: Anonymous 2008-05-09 5:52

Your compiler has too many bits.  Remove some of them.

Name: Anonymous 2008-05-09 7:46

You could make a function that returns the value of the n'th thing in the enumerator.

Name: Anonymous 2008-05-09 7:52

>>11
You could call it operator[].

Name: Anonymous 2008-05-09 7:56

INT MEGA STRUCT LOL WHAT

Name: Anonymous 2008-05-09 8:27

>>12
moar

Name: Anonymous 2008-05-09 15:22

test

Name: Anonymous 2008-05-09 16:02

hax my anus

Name: Anonymous 2008-05-09 22:09

>>12
Fuck Sepples

Name: Anonymous 2008-05-10 18:51

[0]

Name: Anonymous 2009-03-06 12:34

Value 0 value Length.

Name: ​​​​​​​​​​ 2010-10-21 14:18

Name: Anonymous 2010-12-24 19:52

Name: Anonymous 2011-01-31 21:22

<-- check em dubz

Name: Sgt.Kabukiman 2012-05-23 5:35

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: Anonymous 2013-09-01 14:46


Infinity is also used to describe infinite series:

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List