Help me /g/, what am I doing wrong here? (C)
This is literally my code and the output is literally what happens. This shouldn't be happening, I am in charge here!
>>58285346double a[2];
double b[2];
a[n] allocates an array of size n so the max index is n - 1
what you're seeing here is an issue undefined behavior
>>58285380
Yes, I am LITERALLY using (n-1), so 1 as max index. I never use a[2] or b[2] on the picture.
>>58285346
what do you think should happen? seems fine to me
>>58285401
n-1 is 0 fucktard, not 1
>>58285415
lol it works now thx
>>58285401
if you have an array of size n (double a[n]) you can index it from 0 to n-1 (including 0 and n-1)
if you turned on compiler warnings you would've seen an out of bounds warning
>>58285460
>if you turned on compiler warnings you would've seen an out of bounds warning
lel
>>58285346
That's a big program 4.000000 you
>>58285598
I don't get it
>>58285598
kek
>>58285346
why such pajeet bro
just int a[1] lmao
>>58285460
>if you turned on compiler warnings you would've seen an out of bounds warning$ gcc -Wall -Wextra test.c -o test
$
change all of the %f
to
%1.0f
post result
>>58288004
what gcc version?
try with -Wextra too
>>58285346
>programming C on Windows
truly blasphemous
>>58285694
you must be new here
>>58285694
fucking newfags i swear
>>58288895
They used -Wextra already
>>58289023
What language do you think most Windows software is written in?
>>58285346
>>58285380
>>58285401
Is this a meme? We've had similar threads 4 days in a row now.
>>58289215
>>58289528
>a-am i fitting in yet?