samedi 25 avril 2015

can't get string conversion strtod in c (fixed)


Could somebody help me(sorry for the english), Im trying to convert a string to a double but when I can't get it here's my code(thank you, I'll appreciate help so much):

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_LONG 5

char bx[MAX_LONG];
double cali=0;

int main() {                              /*(here */
scanf("%s",bx); /*here was the error scanf("%c",bx)*/
cali = strtod(bx,NULL);
printf("%f",cali);
return 0;
}

when I input a value greater than 10 in the output it just print the first number like this:

 input: 23
 output: 2.00000
 input: 564
 output: 5.00000


Aucun commentaire:

Enregistrer un commentaire