Quick C question

Anthony Gabrielson agabriel at home.tzo.org
Wed Nov 16 10:54:24 EST 2005


Thanks - That worked like a champ :).

Anthony

On Wed, 16 Nov 2005, Seth Gordon wrote:

> Ooh!  Ooh!  Ooh!  Mr. Kotter!
> 
> > #include <stdio.h>
> > 
> > #define	D1	4
> > #define	D2	2
> > 
> > int main(){
> > 
> > 	int *array;
> 
> Here you're defining "array" as a pointer to an int.
> 
> > 
> > 	array = malloc(sizeof(int) * (D1 * D2));
> > 
> > 	array[1][1] = 32;
> 
> Here you're using "array" as a pointer *to a pointer* to an int.
> 
> > 
> > 	printf("Elem[1][1] = %d\n",array[1][1]);
> > 	
> > 	free(array);
> > 
> > 	return 0;
> > }
> 
> Try changing "int *array" to "int **array".
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://olduvai.blu.org/mailman/listinfo/discuss
> 



More information about the Discuss mailing list