Lose of array data

Started by
4 comments, last by Nikita21 16 years, 7 months ago
I really can`t put my finger on this one, here is a chunk of codes relevant to the problem : when am attempting to store the question index value inside the subscript array, in a structure, i seem to be losing the data. Question index, accept the value of the question number enumerated Thanks in advance. [Edited by - Nikita21 on September 19, 2007 12:45:08 AM]
Advertisement
An array of size 6 only allows indices between 0 and 5 inclusive. Accessing element 6 will not produce any kind of reliable effect, so don't do it.
There's also nothing meaningful in the index array -- you never initialize it, so it has garbage data. I assume there's actually more to the code than this?
Thanks for the help. there is much more to learn.

within or outside of the data structure?

[Edited by - Nikita21 on September 19, 2007 12:28:47 AM]
Stop. What are you really trying to do? In English, please, not code (since that isn't getting anywhere right now). What kind of thing do you want to pass to the function? What do you want to get out? What do you want to happen as a side effect? And what are these data structures? A name like "Data_Storage" is about as perfectly unmeaningful as it gets.
I am trying to store values returned from a function, within arrays.

I have a function, that generate a random number using rand().

Am trying to return the value generated by rand() to another function, that will store that value.

So i will be able to avoid from the value generated by rand, from been reused.

Somehow am trying to store the value`s generated within array, for later use, so i will be able to avoid them. like a mini storage.
however, i am unable to store these values in local scope arrays, since they will cease to exist, once the function will end.

Sorry if i am not clear enough, sometimes am having problems to express myself right.

This topic is closed to new replies.

Advertisement