The following is a part of a program I was trying to write. The problem is that
if the for loop is used flPart will be incorect. If it is cut everything works just
fine.
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
double atod_new(char* stg);
int main()
{
atod_new("453,43.5435");
return 0;
}
double atod_new(char* stg)
{
char* stgClean = "\0";
int j = 0;
// THIS LOOP CAUSES
for (int i = 0; stg[i] != '\0'; i++)
{
if (stg[i] >= '0' && stg[i] <= '9' || stg[i] == '.') stgClean[j] = stg[i];
else j--;
j++;
}
stgClean[j] = '\0';
long intPart = atol(stgClean);
char* point2Fl = strchr(stgClean, '.');
point2Fl++;
double flPart = 653.;
cout << endl;
cout << flPart << endl;
flPart= flPart/10;
cout << flPart; // THIS TO OUTPUT NONSENSE
return flPart;
}