Many thanks. I overlooked that.
Type: Posts; User: thames
Many thanks. I overlooked that.
Ok, I coded a simple representation of an extended Atof:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
I will search for it.
edit:
Can you show me a good link about the algorithm process?
I see, you're completely right.
what I wrote so far.
I almost got a scientific notation:
Please enter a double: -0.00012345
The double value in scientific notation is -12345e-8
I solved the final problem (convert a number like 125.5 to 1.255e+2) using sprintf. However my array got a lot of junk.
edit:
I still didn't fix the output of a number like -125.5
gdb...
I decided, for now, to put every necessary function inside the main source because is easier to handle everything that way. Why is 0.050000000000000003 the value of val when I input 0.05 as a string...
Now I'm only testing numbers like 0.05.
#include "../Headers/conversion.h"
#include <stdlib.h>
void itoa(int n, char* s)
{
int sign, i;
Sorry for that. From now on, I'll comment the codes with certain level of complexity.
I thought I could do that because of itoa's code snippet:
do {
s[i++] = abs(n % 10) + '0';
strsci = strcat("e+",strnpow);
Conversion/atof.c:39:6: warning: passing argument 2 of ‘strcat’ makes pointer from integer without a cast [enabled by default]
why did I get pointer from integer...
Good afternoon. I'm trying to code a program which converts a string in a double and in a string again but with scientific notation.
The exercise is from KnR:
Extend atof to handle scientific...