I've converted a float into an char array that will be sent over to a server. I want to be able to convert the char array, say from buffer[10]... to buffer [20] converted back into a single float. How can i accomplish this? I only know how to convert entire buffer using atoi but since my char buffer will contain other irrelevent data how can i selecetively do this for certain part of my array?
This is how i converted my float into an char array.
sprintf(game->buffer,"%f",game->man[playerNumber-48].x);
//printf("%s\n", game->buffer);
for(int i = 0; i<11;i++)
{
game->send_key_to_server[i+8] = game->buffer[i];
}
sprintf(game->buffer,"%f",game->man[playerNumber-48].y);
for(int i = 0; i<11;i++)
{
game->send_key_to_server[i+19] = game->buffer[i];
}
Basically im sending my players x and y cordinates over to the server as chars.