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

Pages: 1-4041-8081-

POINTERS, STACK, CODESPACE, ETC

Name: Anonymous 2008-05-25 17:58

http://i30.tinypic.com/2z5itg5.jpg

Read and enjoy the lesson

Name: FULLFORCE 2008-05-25 18:00

Proper English, nigger, do you know it?

Name: Anonymous 2008-05-25 18:26

>>1
you know it's a pointer because of the star before the name
Orly?
Is char *array[123]; a pointer too? (hint: it's an array)
When you make a pointer, you basically make a variable that holds an address instead of a value.
An address is a value. You don't "make" pointers or variables.
You define them.
Another way to declare an array is something like
char s[]

You cannot define an incomplete object, such as char s[];
And you don't declare arrays, you define them.
Learn the difference between declare and define.
The difference is that here, the array is on the stack.
Actually, C doesn't have "stacks", nor "heaps".
(like an 'if', 'while' function, etc)
if and while are keywords, not functions.
Your last snippet, in particular:

int main(void) {
char s[1024];
main();
return (0);
}

Invokes undefined behavior, it doesn't "overflow" the stack.
In particular, see 5.2.4.1 Translation limits.
Plus, a compiler is free to ignore the unused object 's', and the never reached return, and optimize right away to an infinite loop.

And that's my lesson for you today.

Name: Anonymous 2008-05-25 18:37

>>3
my god you're a retarded little nigger, eh?

1.  char *array[123] IS a pointer.  It points to the head of an array of strings.

2.  Define and make are interchangeable terminology.

3.  GODDAMN, you don't know what the 'stack' and 'heap' are in memory hierarchy??  fucking just kill yourself now.

Name: Anonymous 2008-05-25 18:43

>>1
Back to /b/ please

Name: Anonymous 2008-05-25 18:44

>>4
1.  char *array[123] IS a pointer.  It points to the head of an array of strings.
No, char *array[123] is an array of 123 pointers to char.
A pointer to an aray of 123 char would be char (*array)[123]
2.  Define and make are interchangeable terminology.
Not according to the standard.
3.  GODDAMN, you don't know what the 'stack' and 'heap' are in memory hierarchy??  fucking just kill yourself now.
They don't exist in the standard.

Name: FULLFORCE 2008-05-25 18:46

TROLL DETECTED.

Name: Anonymous 2008-05-25 19:00

DETECTOR TROLLED.

Name: Anonymous 2008-05-25 19:05

OBSERVER SAGED.

Name: Anonymous 2008-05-25 19:08

DETECTOR DETECTED

Name: Anonymous 2008-05-25 19:10

SAGE OBSERVED

Name: Anonymous 2008-05-25 19:20

DEVRESBO EGAS

Name: Anonymous 2008-05-25 19:24

>>6
A char pointer is basically a string
A char array is basically a char pointer


int main(int argc, char *argv[]) {
  int i = 0;
  while (i<argc)
    printf("%s\n", argv[i++]);
  return(0);
}


You're correct, the mem stack/heap aren't in the standard, but they ARE standard to x86 architecture, which is what most of us program on, and probably what you're using to post.  GTFO

Name: Anonymous 2008-05-25 19:32

It's a great explanation, you know because I say fuck in every second sentence.

Name: Anonymous 2008-05-25 19:55

The fact that this is an image and speaks like /b/ makes me think that this is from a /pr/. /pr/ nomads.

Name: Anonymous 2008-05-25 20:13

Hah.  >>3,6 owned >>4 like the little nublet he is.

well done, anon.

Name: Anonymous 2008-05-25 20:51

>>13
Posting from the Sun

Name: Anonymous 2008-05-25 20:59

>>2-17
>>19-999

JAVA CONSPIRACY

Name: Anonymous 2008-05-25 21:26

You want to know what drives me nuts? Of course you do.
char *foo declares a variable which stores an address.
*foo looks up the value at the address stored in a variable.
&foo gets the address of a variable.
And now this is required: foo->bar.

Is there some reason we not only need to give * two different meanings, but also need to introduce two more types of line noise? Was there anything stopping us from having an address operator that worked on both these types of data, and automatically dereferencing pointers? Of course there wasn't. Except that would have been too logical.

Name: Anonymous 2008-05-25 22:22

>>19
The declaration is designed to reflect its usage.

Name: Anonymous 2008-05-25 22:28

>>13
Actually, I'm posting this from my Nintendo DS.

Name: Anonymous 2008-05-25 22:32

C style pointers are fuckign stupid as fuck.

Give me a real OO language (hint: not C++) that has object and value variables.

Name: HAX MY ANUS MEME FAN 2008-05-25 22:42

>>22
C pointers have no overhead to speak of, so they're very fast and efficient. That's their quality, it makes them good for realtime processing or intensive applications where efficiency matters more than speed of coding. For the rest, there are intelligent pointer classes (eg boost's), and garbage collection.

I just wrote a decent post on /prog/ and I  f e e l  k i n d  o f  b a d  a b o u t  i t :-(

Name: Anonymous 2008-05-25 22:51

>>23

That wasn't a decent post, you cancerous piece of shit. Go deref yourself in a cold dark corner. I'm an EXPERT PROGRAMMER and I don't have to explain myself.

[b]hax my anus[b]

Name: HAX MY ANUS MEME FAN 2008-05-25 22:52

>>24
[b]hax my anus[b]
I shall do so with great joy, old chap.

Name: Anonymous 2008-05-25 22:55

>>23
You are a weird person, HMA fan.

>>24
You are not EXPERT, your BBCode failed

Name: Anonymous 2008-05-25 22:55

>>20
Which makes a modicum of sense, until you come to the part where * in a declaration means "this is a pointer" and * elsewhere means "this is no longer a pointer". Should have just used * to get the address of any variable and also in declarations.

Name: Anonymous 2008-05-25 23:00

>>22
Remember that OO is just syntactic sugar for structs with methods. Just look at the gtk api. You may write gtk_widget_show(GTK_WIDGET(my_widget)) as my_widget.show(). Does the same fuqin shit, but with better syntax and associating the method to the type.

Name: Anonymous 2008-05-25 23:01

>>1
You are the cancer killing computer science and /prog/.

Name: Anonymous 2008-05-25 23:04

>>29
He's called /pr/

Name: Anonymous 2008-05-25 23:15

>>28
OO is just syntactic sugar for structs with methods.

RAAAAAAAAAAAAAAGE!

Don't come into my /prog/ perverting OO like that. What the hell kind of OO is it when you can't send any message to any object?

associating the method to the type.

This ruins OO. So much for abstraction, eh?

Name: Anonymous 2008-05-25 23:17

>>28
If your understanding of OO is that shallow, then it's no wonder why people here rage like they seriously misunderstand it. OO is a modelling tool that is well suited to problems that are easily classified into objects that communicate by passing messages. This is how you're supposed to approach OO design.

Name: Anonymous 2008-05-25 23:39

>>31,32
It's a different point of view. Yours is enterprise. But I think OO is overrated.

About the fundamental feature you call ``messages'', most OO implementations i've seen lack a built-in implementation of signals (if that is what you mean, perhaps I misunderstood). Implementing it manually is often piece of cake: a function that sends, another that receives, or some variation of that. It may be still like a function in a struct: the identity of the object, if you prefer calling it that way, is kept within it fields, and signals or messages may be still interpreted in different ways according to such fields.

This signal or message thing is, then, a fancy way to say "method call", where method is a fancy way to say "function associated with struct".

What I find strange is that you are defending OO without mentioning the only feature that is worth, inheritance.

Name: Anonymous 2008-05-26 1:47

>>33
Mine is ENTERPRISE? Are you completely ignorant of OO outside of whatever cudderforsaken language you've convinced yourself is usable? "Method call" is a confused way to say "send a message". In OO, objects have methods to respond to messages, and when an object is sent a message that it does not understand, it has a method for that too. Methods are implementation details and are distinct from messages. A programmer using an object never needs to know whether it implements a particular method or not (although it is helpful to know if that object has a strategy for managing your message).

Your talk of "fancy ways" betrays your deep misunderstanding. You're trying to phrase OO in Ctard terms when OO and the terms associated with it were defined before C ever arrived. C structs and functions can be used to approximate usable OO, but that does not make them its substrate.

Lastly, I'm not >>32, who pretty clearly doesn't understand OO. OO isn't a modeling tool, it's a tool for easily writing programs that require extreme late binding. It's not the only tool for that (Lisp and functional languages are good for this too), but that is its purpose.

Name: Anonymous 2008-05-26 4:18

>>34
http://en.wikipedia.org/wiki/Object_oriented_design
What is written in WP is exactly what I was taught about OO design. While you can exploit the properties of OO design to perform late binding, I sincerely doubt that OO was intended for that purpose.

Name: Anonymous 2008-05-26 8:52

I can't tell if you idiots are serious or just trolling. Because some of these posts are just fucking awful in every way, but too clever to be trolls. Such as >>34
>>33
>>32

Name: Anonymous 2008-05-26 9:00

PROTIP:Trolls have to be smart to succeed. Otherwise they're just ignorant twats

Name: Anonymous 2008-05-26 11:26

i dont get it. what is oo? is it that ghostly voice like oooOoOOOOooOo?

Name: Anonymous 2008-05-26 11:28

>>38
object-oriented

Name: Anonymous 2008-05-26 12:58

>>1
Holy crap.  Thank you.  I never really knew how pointers worked.  And thanks for no fucking hax my anus reference.  You should make more of these

Name: Anonymous 2008-05-26 13:15

>>39
[b]DON'T HELP HIM!![b]

Name: Anonymous 2008-05-26 14:10

>>19
(*foo).bar

>>40
You best be trolling.

Name: Anonymous 2008-05-26 14:54

>>42
Can you assign to that?

Name: Anonymous 2008-05-26 16:13

>>35
OO's inventor would disagree with your idiot teachers.

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.
-- Alan Kay

Q.E.D.

Name: Anonymous 2008-05-26 16:25

>>43
I think so. You'd be assigning foo's bar.

Name: Anonymous 2008-05-26 17:57

>>44
—Anal Gay

Name: Anonymous 2008-05-26 18:33

>>46
—Anal Gay, the inventor of OOP.

Name: Anonymous 2008-05-26 19:35

>>44
http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht73Ht/doc_kay_oop_en
Well according to this, we're both right. According to the inventor of the term, OO is about self contained objects (cells that abstract, protect and encapsulate data) that communicate by passing messages (which is exactly what I was taught) AND do late binding do to their work (which was not taught and I've never bothered to think about).

Name: Anonymous 2008-05-26 20:58

>>48
I'm glad you halfway understand OOP.

Name: Anonymous 2008-05-26 21:11

char *hax = "my anus";
printf("%x", &hax);
printf("%x", hax);
printf("%x", *hax);
Anus was haxed

Name: Anonymous 2008-05-26 21:42

>>1

Good job.  Write moar plox.  Srsly.

Name: Anonymous 2008-05-26 22:07

>>4
you forgot the fact that this:
int main(void){
  char s[1024];
  main();
  return(0);
}


is the same as this:
int main(){
 for(;;);
 return 0;
}


unless your compiler is absolute shit.

Name: Anonymous 2008-05-26 23:04

>>52


you forgot the fact that this:
[code]int main(void){
  main();
  return(0);
}


is the same as this with -funroll-loops:
int main(){
 for(;;);
 return 0;
}


unless your compiler is absolute shit.

Name: Anonymous 2008-05-26 23:22

>>53
[gcc bullshit]

Please refer to >>52
unless your compiler is absolute shit

Name: Anonymous 2008-05-27 0:02

>>54
BUT ITS SO FUN, BECAUSE IT FUN ROLL LOOPS LOL!!!!!

Name: Anonymous 2008-05-27 0:36

>>55
Does funroll-loops remind anyone else of Fruit Roll-Ups?

Name: Anonymous 2008-05-27 0:57

>>56
Man, I thought I was the only one.

Name: Anonymous 2008-05-27 7:38

>>53
-funroll-loops

RAGE at minor optimization instead of improved algorithms

Name: Anonymous 2008-05-27 8:09

>>58
instead of
RAGE at retarded assumptions instead of using everything at your disposal

Name: Anonymous 2008-05-27 8:52

>>58
RAGE at minor optimization instead of improved algorithms
-funroll-loops unrolls loops.
If you manually unroll a loop, the algorithm is changed; therefore -funroll-loops achieves more speed by changing the algorithm.

Name: Anonymous 2008-05-27 10:26

Only niggers funroll their loops.

Name: Anonymous 2008-05-27 19:16

>>59
If you manually unroll a loop, the algorithm is changed; therefore -funroll-loops achieves more speed by changing the algorithm.
Does not amount to an improvement in asymptotic runtime. Fail.

Name: Anonymous 2008-05-27 21:05

>>60
That's not a change in the algorithm.

Name: Anonymous 2008-05-27 21:10

>>63
Yes it is.

Name: Anonymous 2008-05-27 22:07

>>64
No it isn't.

Name: Anonymous 2008-05-27 22:10

>>65
Yes it is.

Name: Anonymous 2008-05-27 22:11

>>1

which is more efficient in asm, using mov or lea when dealing with addresses?

Name: Anonymous 2008-05-27 22:12

>>66
No it isn't.

Name: Anonymous 2008-05-27 22:12

>>67
mov

Name: Anonymous 2008-05-27 22:12

>>69
lea

Name: Anonymous 2008-05-27 22:14

>>70
mov

Name: Anonymous 2008-05-27 22:16

>>66
No it isn't, fool/faggot. Fagool.

Name: Anonymous 2008-05-27 23:16

>>68,72
Yes, it is.

Name: Anonymous 2008-05-28 0:31

I love the last part.

Infinite memory assignment loop in my /prog/?

Name: Anonymous 2008-05-28 0:34

8==============D

Name: Anonymous 2008-05-28 0:47

>>67

I wonder this as well. How many clock cycles does it take to MOVL as opposed to LEA?

Name: Anonymous 2008-05-28 0:57

>>76
Depends on the processor.

Name: Anonymous 2008-05-28 1:16

>>77

How would one go about learning of these things?

Name: Anonymous 2008-05-28 1:54

>>78
Read IASDM.

Name: Anonymous 2008-05-28 6:43

That infinite memory allocation loop is complete fail.

If you are using a decent OS it will kill the program. If you debug it it will tell you there was a stack overflow.

Name: Anonymous 2008-05-28 6:48

If you are using a decent OS it will kill the program.
unless you're using a decent compiler, which will optimize away the allocation because the memory isn't used and optimize the tail-recursion into a loop.

Name: Anonymous 2008-05-28 7:09

>>81
Might make sense if that function had any tail recursion.

Name: Anonymous 2008-05-28 7:53

>>76
less. LEA does a whole bunch of other stuff besides move

Name: Anonymous 2008-05-28 9:42

>>79
Read SICP.
Oh hey you had a little mistake in your post, fixed it since it was pretty obvious.

Name: Anonymous 2008-05-28 13:35

>>84
Using SICP as a reference book for low-level architecture-dependent programming considered harmful

Name: Anonymous 2008-05-28 15:08

>>82
the code after main(); is unreachable, making it equivalent to this:
int main(void){
  char s[1024];
  return main();
}


s is unused, which makes it equivalent to this:
int main(void){
 return main();
}


which is equivalent to this:
int main(void){
 for(;;);
}

Name: Anonymous 2008-05-28 15:16

I rage when I read this thread. I can't believe there are so many clueless programmers here.

Name: Anonymous 2008-05-28 15:40

>>87
YHBT

Name: Anonymous 2008-05-28 18:48

>>40 has not read his K&R.

Name: Anonymous 2008-05-28 19:41

Name: Anonymous 2008-05-28 19:50

>>90

HOLY SHIT
IS THIS REAL? I MUST KNOW

Name: Anonymous 2008-05-28 19:54

>>91
Yes. Additionally, the person holding the sign is a male.

Name: Anonymous 2008-05-28 19:56

>>91
Believe.

Name: Anonymous 2008-05-28 19:57

>>92
As in ``it has a penis''?

Name: Anonymous 2008-05-28 20:01

>>91-94
That was posted to /s/ some days ago, and to /prog/ when the other thread was still alive. Lurk moar.

Name: Anonymous 2008-05-28 21:06

>>94
N-n-nooooooooooooooooooo!!!!!! You're lying!

Name: Anonymous 2008-05-28 21:17

>>94
Yes, that would be the definition of a male.

Name: Anonymous 2008-05-28 21:47

>>90
1) That's a woman, not a man, you can tell by the jaw and hands.
2) It's photoshopped.

Name: Anonymous 2008-05-28 21:54

>>97
So most birds don't have a male gender?

Name: Anonymous 2008-05-28 22:34

>>99
gb2/orn/

Name: Anonymous 2008-05-29 3:29

>>99
Correct.

Name: Anonymous 2008-05-29 9:50

>>99
I can tell that you (hereafter referred to as ´´bitches´´) don't know about my male bird of unusual size (hereafter referred to as ´´huge cock´´).

Name: Anonymous 2008-05-29 9:51

>>98
ad. 2
Yep, look at the /prog/snake's eye. It's fake.

Name: Anonymous 2010-12-22 4:17

Name: Sgt.Kabukiman匭眿 2012-05-23 6:07

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: bampu pantsu 2012-05-29 3:35

bampu pantsu

Name: Anonymous 2012-10-23 19:26

ANCIENT THREAD RESURRECTED

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