printf - C Programming - integer value printing incorrectly -



printf - C Programming - integer value printing incorrectly -

i'm using borland c v3.1 (dos version)

this code

#include<stdio.h> #include<conio.h> void wtf() { int array[15],i; int wtf_number=12345; for(i=0;i<16;i++) array[i]=0; printf("%d",wtf_number); } void main() { clrscr(); wtf(); getch(); }

i should 12345 output, i'm getting 0 instead. help.

your code incorrect.

instead of

for(i=0;i<16;i++) array[i]=0;

you should have

for(i=0;i<15;i++) array[i]=0;

since array has 15 elements.

c printf

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -