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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -