hello dp,, programming question > how can I make this number 99,999,999,999.99 omit the comma in c language? in order for me to convert this number to word... thanks for replies... please help me.... please
just erase the commas c++ solution: std::string num = "99,999,999,999.99"; size_t pos; while( (pos = num.find(',')) != string::npos) { num.erase(pos,1); } Code (markup): c solution: int main(int argc, char** argv) { char num[] = "99,999,999,999.99"; char* c; while( (c = strchr(num,',')) > 0) { memmove(c, c+1,strlen(c+1)); } printf("%s\n", num); } Code (markup):
Thank you very much sir Ancient Dragon, thanks. Sir, I have a problem about holding billions of numbers? what particular data type I can used?
All data types have their limitations (maximum values). For your compiler check the header file limits.h which contains the max value for each data type. Most c and c++ compilers now support 64-bit integers which can probably hold the numbers you are using, but check limits.h.
Ok I'l try it sir. Thanks. anyway sir, is their any possibilities of chopping those number by places?
>>any possibilities of chopping those number by places You mean add the commas? Yes -- you try it yourself. And please stop calling me "sir" because I had to actually work for a living.