почему эта программа не компилируется с пользовательским вводом имени файла [duplicate]

Для более углубленного подхода прочитайте Сравнение чисел с плавающей запятой . Вот фрагмент кода из этой ссылки:

// Usable AlmostEqual function    
bool AlmostEqual2sComplement(float A, float B, int maxUlps)    
{    
    // Make sure maxUlps is non-negative and small enough that the    
    // default NAN won't compare as equal to anything.    
    assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024);    
    int aInt = *(int*)&A;    
    // Make aInt lexicographically ordered as a twos-complement int    
    if (aInt < 0)    
        aInt = 0x80000000 - aInt;    
    // Make bInt lexicographically ordered as a twos-complement int    
    int bInt = *(int*)&B;    
    if (bInt < 0)    
        bInt = 0x80000000 - bInt;    
    int intDiff = abs(aInt - bInt);    
    if (intDiff <= maxUlps)    
        return true;    
    return false;    
}

2
задан Dan 8 February 2009 в 16:29
поделиться

3 ответа

В строке пути используйте две точки вместо трех.

Также вы можете использовать метод 'c_str ()' для строки, чтобы получить базовую строку C.

output.open(path.c_str());
9
ответ дан Frederick The Fool 21 August 2018 в 06:20
поделиться
0
ответ дан Assaf Lavie 21 August 2018 в 06:20
поделиться

это должно работать:

output.open(path.c_str())

2
ответ дан crashmstr 21 August 2018 в 06:20
поделиться
Другие вопросы по тегам:

Похожие вопросы: