O meu problema é o seguinte tenho um vetor de floats e precisava de converter cada float do vetor para um char. Para tal estou a utilizar a função dtostrf.
O problema é que se quiser converter todos os todos os valores armazenados no vetor dataf teria que criar 10 vetores do tipo char e a conversão só poderia ser um a um.
O que pretendia era converter todos os valores do vetor dataf e guardar o resultado num só vetor.
Por exemplo:
convertia a dataf[1] para char e guardava o resultado numa posição de outro vetor, por exemplo datafr[1].
Este código funciona devido ao temp que passas como argumento ser um ponteiro por si só,mas o resultado está a ser rescrito a cada passagem do ciclo for.
The dtostrf() function converts the double value passed in val into an ASCII representationthat will be stored under s. The caller is responsible for providing sufficient storage in s.
Conversion is done in the format "[-]d.ddd". The minimum field width of the output string (including the '.' and the possible sign for negative values) is given in width, and prec determines the number of digits after the decimal sign. width is signed value, negative for left adjustment.
The dtostrf() function returns the pointer to the converted string s.