View Single Post
Old 01-22-2005, 05:27 AM   #3 (permalink)
silex
Registered User
 
silex's Avatar
 
Join Date: Jan 2005
Posts: 10
silex is on a distinguished road
Hey ender.

At the beginning I would like to thank for this huge post.

When I compiled my program the error of witch I spoke before was following:
The array (non reversed) was printed good: 1. 2. 3.
But... The reversed array appeared like that: 0. 3. 2.
For 3 element array.
The second error, or bug maybe, was very weird for me:
when the putting into array code appeared:
Code:
for (i=0; i < a_elem; i++)   {
           printf("\nelement: ");
           scanf("%d ", &i_array[index]);
           index++;
}
The process appeared like that:

Element: 1 //pressed enter ??
2 //pressed enter ?? this is the weird thing
Element: 3 //pressed enter etc...


For the first thing I think I got an explanation: The reversed array starts looks like that:
0 1
1 2
2 3
3 4
4 0 // unassigned, but the reversed array starts from here

I don't know what is the problem for the second thing.


Could you explain the following code (I don't understand how the malloc() works) :
Code:
/* Make the array */
   arr = (int *) //esspecialy this part// malloc (numElem * sizeof(unsigned int));
   if (!arr) {
      printf ("Unable to make array!\n");
      return -1;
Dont worry you can explain too much, or too much, or anything else.
I am open for any amount of knowledge (Thats the cause I'm writing and asking)

Thanks again for help,

Jack
silex is offline   Reply With Quote