Jump to content

C++ array question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
PeaceFrogs

PeaceFrogs

    Newbie

  • Members
  • Pip
  • 4 posts
i was looking at some sample code and i noticed something odd about the way someone used an array

he declared it like a normal array:

int a[10]={0};

then he did this:

a[3]++;

any explanation as to what this does would be great and if you could link me to a site that may give an in depth explanation would be most appreciated.

#2
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts
All 10 elements of the array were initialized to zero.
Then element a[3] was incremented.

http://web.archive.o...ft.html#3.3.2.4

#3
PeaceFrogs

PeaceFrogs

    Newbie

  • Members
  • Pip
  • 4 posts
haha i feel dumb now. thank you for your quick response :)