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

Pages: 1-

I found out how to solve the array index problem!!!!

Name: Anonymous 2017-09-06 20:34

void main (){
int numbers[10] = {1,2,3,4,5,6,7,8,9,10};
int *array = &numbers[-1];

printf("%d\n", array[4]);
return 1;
}


Output: 4

Name: Anonymous 2017-09-06 23:07

naice dude, naice

Name: Anonymous 2017-09-07 15:59

What is the benefit of this exactly?

Name: Anonymous 2017-09-07 16:14

>>3
It allows 1-index autists to use C arrays without triggering a meltdown.

Name: Anonymous 2017-09-08 2:53

>>4
doesn't sound like it's worth it tho

Name: Anonymous 2017-09-08 19:45

Isn't that UB?

Name: Anonymous 2017-09-09 1:38

>>6
well, maybe if the pointer gets dereferenced

Name: Anonymous 2017-09-09 8:10

>>7
Or someone writes to array[0]

And what about the (void) 1 return?

Name: Anonymous 2017-09-09 8:26

>>7
Even if it doesn't, it's UB.

Name: Anonymous 2017-09-11 3:17

>>8
And what about the (void) 1 return?
I think that's just a joke, although I see it a lot......
Either way it has nothing to do with arrays

Name: Anonymous 2017-09-11 3:27

I found out how to solve the dubs problem!!!

Name: Anonymous 2017-09-11 15:11

Error: exited with non-zero status.

Name: Anonymous 2017-09-11 16:29

>>12
Compile with -w and no -Werror.

Name: Anonymous 2017-09-12 3:20

>>13
Terrible!

Name: Anonymous 2017-09-16 21:55

Sounds good. How do I automate it?

Name: Anonymous 2017-09-17 0:59

>>15
Preprocessors

Name: Anonymous 2017-09-17 7:52

#include <stdio.h>
#define onearray(type,name,elems,content...) type one__##name [elems]={content};type* name = &one__##name[-1];
onearray(int,array,10,1,2,3,4,5,6,7,8,9,10)
int main(){printf("#2:%d", array[2]);}

Name: Anonymous 2017-09-17 15:26

>>17
UGH

Name: Anonymous 2017-09-18 6:52

>>17
there's Unix way, there's The Right Way (as claimed by Lispers), there's The Right Way (as claimed by Plan9ers), there's The Right Way (as claimed by category-theoryfags) - and then there's the FrozenAnus way

Name: Anonymous 2017-09-21 19:44

>>17-19
Only in C and C++ is this acceptable in production code.

Name: Anonymous 2017-09-21 19:56

>>20
No it's not, because it's undefined behaviour.

Name: Anonymous 2017-09-22 6:34

>>21
how can it be undefined behavior when it's dubs?

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