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

is this bad?

Name: Anonymous 2013-08-27 12:46


struct something floattosomething(float f){
       struct something * ret = (struct something*)malloc(sizeof(struct something));
       ret->type = 3;
       ret->f = f;
       return *ret;
}

Name: Anonymous 2013-08-27 14:52

>>10
why the fuck are you even programming C if you can't even read a goddamn ~200 page book

back to /g/ with your retardation

Name: Anonymous 2013-08-27 14:55

>>11
I read a book on C++ ages ago, so I don't remember some things
but I'm managing without it

Name: Anonymous 2013-08-27 14:59

>>12
Not >>11-san, but have you considered reading a simple C reference? You're missing many basic concepts here, I don't think you're ``managing without it'' as you said.

Name: Anonymous 2013-08-27 15:06

>>13
you guys are saying that it doesn't return a copy? or that copies don't crash it?
if they don't crash it then what crashed it?

Name: Anonymous 2013-08-27 15:08

Name: Anonymous 2013-08-27 15:09

>>14
Your last example does return a copy. Your first post shows you don't know the pointer syntax quite well, so I recommend you to read on that.

I won't be replying anymore.

Name: Anonymous 2013-08-27 15:26

>>15
>>16
so it is a copy
so why does >>1 crash?

Name: Anonymous 2013-08-27 15:33

Name: Anonymous 2013-08-27 16:05

>>17
Post a complete program that crashes.
There's nothing in >>1's snippet that would cause a crash (unless you call this function millions of times and run out of memory due to the memory leak)

Name: Anonymous 2013-08-27 16:29

>>19
mental mid/g/et spotted

Name: Anonymous 2013-08-27 17:04

>>20
how about you fuck off to that board you love so much
dumb kike

Name: Anonymous 2013-08-27 17:08

>>21
and how about you fuck off to that board you love so much

Name: Anonymous 2013-08-27 17:24

Someone please escort >>21,22-san-tachi back to their private subreddit.

Name: Anonymous 2013-08-27 18:12

>>23
who are you callin/g/ a tachi, nigger?

Name: Anonymous 2013-08-27 18:16

>>24
貴方と>>21さん、もちろん。

Name: Anonymous 2013-08-27 19:20

Yes, that is very bad. Upon returning the intended value, you have left the memory allocated for ret to sit there until the program's termination. Don't use pointers unless they're necessary, else you will be leaking memory.

Name: Anonymous 2013-08-27 20:09

倍黒人達

Name: tyrone namibi 2013-08-27 20:20

>>27
who you calling a kurojin, bitchnigga

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