A
arnuld
PURPOSE: see the comments.
WHAT I GOT: infinite loop
/* This program will simply create an array of pointers to integers
* and will fill it with some values while using malloc to create
* pointers to fill the array and then will print the values pointed
* by those pointers
*
*/
#include <stdio.h>
#include <stdlib.h>
enum MAXSIZE { ARRSIZE = 100 };
int main( void )
{
int* arr_p[ARRSIZE];
int** pp;
int *mp, *np;
int i;
int null_int = 0;
pp = arr_p;
np = &null_int;
for( i = 0; i < ARRSIZE - 1; ++i )
{
mp = malloc( sizeof( int ) );
mp = &i;
arr_p = mp;
}
arr_p = np;
while( **pp )
{
printf("**pp = %d\n", **pp);
}
return 0;
}
WHAT I GOT: infinite loop
/* This program will simply create an array of pointers to integers
* and will fill it with some values while using malloc to create
* pointers to fill the array and then will print the values pointed
* by those pointers
*
*/
#include <stdio.h>
#include <stdlib.h>
enum MAXSIZE { ARRSIZE = 100 };
int main( void )
{
int* arr_p[ARRSIZE];
int** pp;
int *mp, *np;
int i;
int null_int = 0;
pp = arr_p;
np = &null_int;
for( i = 0; i < ARRSIZE - 1; ++i )
{
mp = malloc( sizeof( int ) );
mp = &i;
arr_p = mp;
}
arr_p = np;
while( **pp )
{
printf("**pp = %d\n", **pp);
}
return 0;
}