Click here to Skip to main content
15,917,481 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: include text file in program Pin
Steve L.26-Aug-03 4:58
Steve L.26-Aug-03 4:58 
GeneralRe: include text file in program Pin
Blake Miller26-Aug-03 13:53
Blake Miller26-Aug-03 13:53 
GeneralRe: include text file in program Pin
Abin26-Aug-03 14:13
Abin26-Aug-03 14:13 
GeneralRe: include text file in program Pin
Braulio Dez26-Aug-03 1:02
Braulio Dez26-Aug-03 1:02 
GeneralDouble data type validation Pin
Anonymous25-Aug-03 14:48
Anonymous25-Aug-03 14:48 
GeneralRe: Double data type validation Pin
Navin25-Aug-03 15:00
Navin25-Aug-03 15:00 
GeneralRe: Double data type validation Pin
Anonymous25-Aug-03 20:20
Anonymous25-Aug-03 20:20 
GeneralRe: Double data type validation Pin
Abin26-Aug-03 3:10
Abin26-Aug-03 3:10 
OK if you really need some detailed ideas on validating a "double"... Let's see, a double should consist of three types of characters:

sign (+ or -), at most one, and, if any, must be the leading character.
point (.), at most one, must follow at least one digit, and must not be the last character.
digits (0-9), as many as there can be.

So here's an example:
BOOL IsDouble(LPCTSTR lpStr)
{
    BOOL bHasPoint = FALSE; // Already has a point?
    const int LEN = _tcslen(lpStr);
    for (int i = 0; i < LEN; i++)
    {
        if (lpStr[i] < _T('0') || lpStr[i] > _T('9'))
        {
            // Not a digit, then what it is?
            if (lpStr[i] == _T('+') || lpStr[i] == _T('-'))
            {
                // if there's a sign, it must be the leading char
                if (i != 0)
                {
                    return FALSE;
                }
            }            
            else if (lpStr[i] == _T('.'))
            {
                if (bHasPoint
                    || i == 0
                    || i == LEN - 1
                    || (lpStr[i - 1] < _T('0') || lpStr[i - 1] > _T('9')))
                {
                    // point can occur only once,
                    // point must not be the leading char
                    // point must not be the last char
                    // point must follow a digit
                    return FALSE; 
                }
                else
                {
                    bHasPoint = TRUE;
                }
            }
            else
            {
                return FALSE; // definitely not a double
            }            
        }
    }
    return TRUE; // Validated
}

Above code were typed directly in this reply and have not been tested in any compiler, so if there are any typo or errors I apologize, but I think this at least should partially answer your question.
Generalsetting the application icon at runtime Pin
Jim Crafton25-Aug-03 13:58
Jim Crafton25-Aug-03 13:58 
GeneralRe: setting the application icon at runtime Pin
Navin25-Aug-03 14:51
Navin25-Aug-03 14:51 
GeneralRe: setting the application icon at runtime Pin
Jim Crafton25-Aug-03 16:38
Jim Crafton25-Aug-03 16:38 
GeneralRe: setting the application icon at runtime Pin
Toni7825-Aug-03 20:36
Toni7825-Aug-03 20:36 
GeneralRe: setting the application icon at runtime Pin
DaFrawg29-Sep-03 2:27
DaFrawg29-Sep-03 2:27 
QuestionHow to include dialog in the view Pin
Binayak25-Aug-03 13:20
Binayak25-Aug-03 13:20 
GeneralControl Bars Pin
Xakep25-Aug-03 12:59
Xakep25-Aug-03 12:59 
GeneralRe: Control Bars Pin
Thomas Lau25-Aug-03 16:22
Thomas Lau25-Aug-03 16:22 
GeneralRe: Control Bars Pin
Mike Dimmick25-Aug-03 22:42
Mike Dimmick25-Aug-03 22:42 
GeneralClosing the handle of a dynamically spawned thread Pin
Kuniva25-Aug-03 12:17
Kuniva25-Aug-03 12:17 
GeneralRe: Closing the handle of a dynamically spawned thread Pin
Mike Dimmick25-Aug-03 22:43
Mike Dimmick25-Aug-03 22:43 
GeneralDialog prompts in German - would like to restore to English Pin
Peter Maton25-Aug-03 11:15
Peter Maton25-Aug-03 11:15 
GeneralRe: Dialog prompts in German - would like to restore to English Pin
Peter Maton26-Aug-03 13:08
Peter Maton26-Aug-03 13:08 
Generalcolor table of bitmap Pin
includeh1025-Aug-03 10:34
includeh1025-Aug-03 10:34 
GeneralRe: color table of bitmap Pin
Joaquín M López Muñoz25-Aug-03 10:42
Joaquín M López Muñoz25-Aug-03 10:42 
GeneralSimple question. Pin
Jon Newman25-Aug-03 10:03
Jon Newman25-Aug-03 10:03 
GeneralRe: Simple question. Pin
Joaquín M López Muñoz25-Aug-03 10:39
Joaquín M López Muñoz25-Aug-03 10:39 

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.