Lose of array data

This topic is 3813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I really cant 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]

Share on other sites
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.

Share on other sites
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?

Share on other sites
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]

Share on other sites
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.

Share on other sites
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 values 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.