Tuesday, February 18, 2014

Flummoxed - Please Help!

Newsgroup: comp.lang.c++

Subject: Flummoxed - Please Help!

From: mrc2323@...

Date: Tue, 18 Feb 2014 12:40:26 -0700



I have the following (rather simple, I think) code which compiles but

executes in a bizarre way: the code in the subprogram is skipped when

called. 8<{{

Here's the code and the call to it I use:



string spellNumber(double value)

{

bool showThousands = false;

bool allZeros = true;

int ii, dPos, nn;

char wc;

string digits, temp;

ostringstream ossw;

static string builder;

ossw.str("");

ossw << value;

digits = ossw.str();

dPos = digits.find('.');

if(dPos != string::npos) digits.erase(dPos);

nn = digits.length();

wc = digits.back();

for(ii = digits.length()-1; ii >= 0; ii--)

{

int ndigit = (int)(digits[ii]-'0');

int column = (digits.length()-(ii+1));

} // for

// more code to be added here

return builder;

}

...

spellNumber(123.45); // call the function



I have, of course the normal stdafx.h header and "use namespace

std;", and this is code from a small test program I use to debug new

functions and such. Many other programs and many thousands of lines of

code work fine, but this code is weird...and I can't see what's wrong

with it!

Please advise... TIA



---

This email is free from viruses and malware because avast! Antivirus protection is active.

http://www.avast.com









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/O7tKtA

View all the progranning help forums at:

http://ift.tt/1dP9txN

No comments:

Post a Comment