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

C problem

Name: Anonymous 2012-01-18 19:35

Is the behaviour of this program well defined?

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

int main() {
    size_t num, min, max;
    if(scanf("%zu%zu%zu", &num, &min, &max) != 3) return 0;
    if(min >= num || max >= num || min > max) return 0;
    int *arr = calloc(num, sizeof(*arr));
    if(!arr) return 0;
    int *x = arr + min, *y = arr + max, *z = arr + (y - x);
    *x = 1, *y = 1, *z = 1;
    return 0;
}

Name: Anonymous 2012-01-21 4:05

>>39
What if num is 0?
implementation defined

the rest is undefined

Name: Anonymous 2012-01-21 8:38

printf("%zoom %zoom %zoom",mazda3,mazda5,mazda6);

Name: Anonymous 2012-01-22 4:21

>>44
Nice dubz bro.

Name: Anonymous 2012-01-22 4:29

>>43
thanks bro

Name: Anonymous 2012-01-22 5:39

Well for one thing arr + max is clearly out of bounds.

Name: Anonymous 2012-01-22 9:05

Can anyone help me to get passed this :  int[] array = new int[verk2_tala1.Value, verk2_tala2.Value, verk2_tala3.Value];

Error    3    Cannot implicitly convert type 'decimal' to 'int'.

Name: Anonymous 2012-01-22 9:11

>>46
Nigga what the fuck are you doing?


int array[] = { v1,v2,v3 };

Name: Anonymous 2012-01-22 11:31

>>45
nope, num > max

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-22 11:49

>>48
And I'm sure you're also aware of the fact that unsigned arithmetic in C doesn't follow regular addition and subtraction rules.

Name: kodak_galllery_programmer !!kCq+A64Losi56ze 2012-01-22 11:59

>>49
So in other words, could it be....

no way....


wait for it...













YOU MIGHT NOT ONLY HAVE UNDEFINED BEHAVIOR, BUT YOU WILL MIGHT ALSO HAVE A MEMORY LEAK.




WELCOME TO C. THE LANGUAGE THE PROVIDES YOU WITH ENOUGH TOOLS TO FUCK YOURSELF.

Name: Anonymous 2012-01-22 12:10

>>49
>>50
you seem really tense these last few days with your posts.

Did they announce when you're officially going to be a jobless_programmer!!kCq+A64Losi56ze?

Name: Anonymous 2012-01-22 12:19

>>51
I was just trying to help this foolholio by pointing out something that isn't obvious.

Name: Anonymous 2012-01-22 12:22

>>52
I'm always here for you kodak-san when you need a shoulder to cry on.

perl girl is dead

Name: Anonymous 2012-01-22 12:49

>>53
Is Uri still fagging up the perl newsgroups? Oh wait, never mind, I can just go wander over there right now.

Name: Anonymous 2012-01-22 14:08

>>51
The good side of him being fired is cosmic justice, the bad side is he'll have even more time to waste here. Oh well, we can always hope for an endless spiral of unemployment, alcoholism and homelessness.

Name: Anonymous 2012-01-22 14:12

>>55
Well, if all else fails, I'll just go pursue my Ph.D in Chemistry.

Name: Anonymous 2012-01-22 14:15

>>56
Why not pursue a meth addiction instead?

Name: Anonymous 2012-01-22 14:16

>>57
Been there, done that.

Name: Anonymous 2012-01-22 14:19

But seriously, ever since Kodak filed chapter 11, I've given a lot of thought about possibly pursuing my Ph.D in Computational Fluid Dynamics at Caltech

Name: Anonymous 2012-01-22 14:20

>>57
I have meth sores.


Never again will i do meth.

Name: Anonymous 2012-01-22 14:20

>>59
Whatever, as long as you fuck off.

Name: Anonymous 2012-01-22 14:22

>>61
You're just mad because you can't make it out of tech support.

Name: Anonymous 2012-01-22 14:25

>>59
Says the guy who has not a clue about elementary mathematics.

Name: Anonymous 2012-01-22 14:26

>>63
Believe it or not, my undegrad degree is in Mechanical Engineering from the University of Wisconsin.

Name: Anonymous 2012-01-22 14:31

>>62
No, I'm annoyed because you're an insufferable cunt.

Name: Anonymous 2012-01-22 14:55

Check my dubs

Name: Anonymous 2012-01-22 21:11

Nobody is even close yet.

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