maybe your only initializing 0 - 99?
test code:
Code
int main()
{
int i = 0;
for(i = 0; i < 10; i++)
{
printf("%d\n", i);
}
return 0;
}
returns:
Code
0
1
2
3
4
5
6
7
8
9
Process returned 0 (0x0) execution time : 0.020 s
Press any key to continue.
:3 take a minute and look at it not sure if it will help. maybe try using a <= clause.
fuck its 3 am been playing to much guild wars. iirc without this lack of sleep in mind a[100] only goes from 0->99 anyways so disregard this post :/ lol
edit:: maybe it wants you to create an array of pointers and pass the memory address of each element of integers to the pointer.
ex:
Code
//Allocate an array of 100 integer pointers and assign the resulting pointer to the appropriately declared variable, ip_arr. Allocate 100 integers and assign the resulting pointers to the elements of ip_arr. Initialize each integer value to -1.
int main()
{
int *ip_arr[100]; //allocate a array of 100 integer pointers and name it ip_arr
int a[100]; //allocate 100 integers and assign their memory location to the 100 pointers
int i = 0;
for(i = 0; i < 100; i++)
{
a[i] = -1; //allocate the interger to -1
ip_arr[i] = &a[i]; //send the address of the current element to the pointer array
}
for(i = 0; i < 100; i++) //some debug stuff you can remove. just wanted to test to make sure each pointer element had the memory address of the integer.
{
printf("%d\n", *ip_arr[i]);
}
return 0;
}
could also want you to allocate the -1 intger through the pointer array.
ex:
Code
for(i = 0; i < 100; i++)
{
ip_arr[i] = &a[i];
*ip_arr[i] = -1;
}
simple mod to see if it actually writes the memory addresses. iirc that would essentially set a[i] to -1 through the pointer.
Code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *ip_arr[10];
int a[10];
int i = 0;
for(i = 0; i < 10; i++)
{
a[i] = i + i;
ip_arr[i] = &a[i];
}
for(i = 0; i < 10; i++)
{
printf("%p: %d\n", &ip_arr[i], *ip_arr[i]);
}
return 0;
}
result:
Code
0028FEF4: 0
0028FEF8: 2
0028FEFC: 4
0028FF00: 6
0028FF04: 8
0028FF08: 10
0028FF0C: 12
0028FF10: 14
0028FF14: 16
0028FF18: 18
Process returned 0 (0x0) execution time : 0.017 s
Press any key to continue.
This post was edited by AbDuCt on Aug 31 2012 04:36am