c array question [closed]

asked 2013-04-02 04:27:50 -0500

updated 2013-04-02 06:05:26 -0500

hhlp gravatar image

Hi I'm new to c language. Can you help me understand this ?

I have a code :

#include<stdio.h>
int main( )
{int a[5]= {1} ;
printf ( "\n%d %d %d %d",a[1], a[2], a[3], a[4] ) ;
return ;
}
when i run it the output is 0 0 0 0 
but when i change a single line which is 
int a[5]= {1} ; to int a[5]; the output is whole garbage value

why it is so?

why one time i getting 0000 as output and other time i get garbage value ?

please explain this to me .

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by Jomoos
close date 2013-04-02 06:15:40.464776

Comments

1

welcome to askfedora this questions should be irrelevant to this community see FAQ however Maybe you could have a better support in a C forum, however if you have a fedora question fell free to ask, thx

hhlp gravatar imagehhlp ( 2013-04-02 06:04:33 -0500 )edit
1

Like @hhlp said, this kind of questions is inappropriate for this community. You may ask this kind of questions on stackoverflow.com. Stackoverflow is specifically created for questions related to programming.

Jomoos gravatar imageJomoos ( 2013-04-02 06:14:54 -0500 )edit