I`m using the following code and it works fine till the last line.atof should convert a string to float.It works fine with atoi(ansi to int).With the atof it turns out weird numbers in the range of thousands. What am I doing wrong? I`d appreciate any help.
code:
Code:void InputStr(char *buffer, unsigned short maxlen) { SCR_STATE ss1; signed short key; unsigned short i = 0; buffer[0] = 0; SaveScrState (&ss1); do{ MoveTo (ss1.CurX, ss1.CurY); SaveScrState (&ss1); if ( i==3 ) {printf ("%s ", buffer);} else printf ("%s_ ", buffer); key = ngetchx (); if (key >= '0' && key <= '9' && i < maxlen) //48-57 buffer[i++] = key; else if (key == KEY_BACKSPACE ) i--; //257 else if (key==173 && i==0) buffer[i++] = key; //(-) else if (key==46)buffer[i++] = key; //comma buffer[i] = 0; } while (key != KEY_ENTER); Input = atof(buffer);//buffer is string }
[code][/code]tagged by Salem



LinkBack URL
About LinkBacks


