You are here:

C/Using pointer in C


I would like to have a question on a piece of code from this forum:


uint8_t *array;
float adc = 1.23456;
array = ftoa( adc, ( int * ) 0 );

1. is uint8_t * array equivalent to char array[] ?
2. If so, it is not declared with size, so where does it end up in the memory ? There was no = new int[x] so it looks like there was no memory allocation.
3. What is the meaning of (int*) 0 ?
It looks like an int pointer that has zero address, so it would be a Null ? if so wouldn't it be an error when trying to reference null pointer ?

Thank you so much!

Hi Ben,

uint8_t is an unsigned eight bit type. The array variable in the code snippet you posted is a pointer to a uint8_t type. uint8_t and char are similar because they are both one byte in size. The implementation details of ftoa will tell you if the memory is allocated or if the memory ends up on the stack. It looks like the meaning of (int *)0 is to pass a null pointer as an argument to the function ftoa. The implementation of ftoa may allow for a null pointer and check for this, so it may or may not be an error.



All Answers

Answers by Expert:

Ask Experts


Tony Nazzal


I will answer any c language programming and syntax questions.


I have almost a decade of c programming experience.

I have a bachelor of science degree and several years of industry experience.

©2017 All rights reserved.