Click here to Skip to main content
15,887,676 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ Thousand Separators Pin
awesometrickycool1-Apr-10 15:49
awesometrickycool1-Apr-10 15:49 
GeneralRe: C++ Thousand Separators Pin
David Crow1-Apr-10 16:26
David Crow1-Apr-10 16:26 
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury1-Apr-10 16:02
professionalJoe Woodbury1-Apr-10 16:02 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool1-Apr-10 16:17
awesometrickycool1-Apr-10 16:17 
GeneralRe: C++ Thousand Separators Pin
David Crow1-Apr-10 16:29
David Crow1-Apr-10 16:29 
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury1-Apr-10 17:05
professionalJoe Woodbury1-Apr-10 17:05 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool3-Apr-10 12:48
awesometrickycool3-Apr-10 12:48 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool3-Apr-10 12:49
awesometrickycool3-Apr-10 12:49 
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    string str(argv[1]);
    int count = 0;
    int i = 0;
    if((str[0] == '-')||(str[0] == '+'))
    {
        count = -1;
    }
    bool firstSegment = true;
    while((count < 4)&&(i < str.size()))
    {
        if((str[i] == 'E' )||(str[i] == 'e')||(str[i] == '.'))
        {
            if((count == 3)||(firstSegment == true))
            {
                i = (str.size() - 1);
            }
            else if(firstSegment == false)
            {
                cout << "X" << endl;
                count = 3;
                i = (str.size() - 1);
            }
        }
        else if(str[i] == ',')
        {
            if(firstSegment == true)
            {
                firstSegment = false;
                if((count > 3)||(count == 0))
                {
                    count = 4;
                }
                else
                {
                    str.erase(i,1);
                    count = 0;
                    i--;
                }
            }
            else
            {
                if(count != 3)
                {
                    count = 4;
                }
                else
                {
                    str.erase(i,1);
                    count = 0;
                    i--;
                }
            }
        }
        else
        {
            count++;
        }
        i++;
    }
    if((count!=3)&&(firstSegment == false))
    {
        cout << "Y" << endl;
    }
    cout << str << endl;
    return 0;
}


That might be a bit easier to read...
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury3-Apr-10 13:04
professionalJoe Woodbury3-Apr-10 13:04 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool3-Apr-10 13:30
awesometrickycool3-Apr-10 13:30 
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury3-Apr-10 15:06
professionalJoe Woodbury3-Apr-10 15:06 
QuestionProblem with glut when linking statically Pin
jocasa1-Apr-10 2:25
jocasa1-Apr-10 2:25 
QuestionRe: Problem with glut when linking statically Pin
CPallini1-Apr-10 2:41
mveCPallini1-Apr-10 2:41 
AnswerRe: Problem with glut when linking statically Pin
jocasa1-Apr-10 2:51
jocasa1-Apr-10 2:51 
GeneralRe: Problem with glut when linking statically Pin
CPallini1-Apr-10 2:58
mveCPallini1-Apr-10 2:58 
GeneralRe: Problem with glut when linking statically Pin
jocasa1-Apr-10 3:00
jocasa1-Apr-10 3:00 
GeneralRe: Problem with glut when linking statically Pin
jocasa1-Apr-10 3:22
jocasa1-Apr-10 3:22 
GeneralRe: Problem with glut when linking statically Pin
LunaticFringe1-Apr-10 3:43
LunaticFringe1-Apr-10 3:43 
GeneralRe: Problem with glut when linking statically Pin
jocasa1-Apr-10 4:12
jocasa1-Apr-10 4:12 
GeneralRe: Problem with glut when linking statically Pin
LunaticFringe1-Apr-10 4:24
LunaticFringe1-Apr-10 4:24 
GeneralRe: Problem with glut when linking statically Pin
CPallini1-Apr-10 6:16
mveCPallini1-Apr-10 6:16 
GeneralRe: Problem with glut when linking statically Pin
Moak1-Apr-10 6:26
Moak1-Apr-10 6:26 
GeneralRe: Problem with glut when linking statically Pin
LunaticFringe1-Apr-10 8:11
LunaticFringe1-Apr-10 8:11 
GeneralRe: Problem with glut when linking statically Pin
CPallini1-Apr-10 9:19
mveCPallini1-Apr-10 9:19 
GeneralRe: Problem with glut when linking statically Pin
jocasa1-Apr-10 9:41
jocasa1-Apr-10 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.