私はこれに長い間苦労してきました。
この最小限のコードがあるとしましょう:
test.cxx
#include <iostream>
#include <cstdio>
int main (int argc, char *argv[])
{
const char *text = "1.01 foo";
float value = 0;
char other[8];
int code = sscanf(text, "%f %7s", &value, other);
std::cout << code << " | " << text << " | => | " << value << " | " << other << " | " << std::endl;
return 0;
}
$ g++ test.cxx; ./a.out
予想どおり、次の出力が生成されます。
$ 2 | 1.01 foo | => | 1.01 | foo |
今、私はこれらの5行を数千行のプロジェクトに埋め込んでおり、多くのインクルード...
コンパイル、実行、および出力は次のようになります。
$ 2 | 1.01 foo | => | 1 | .01 |
この不一致の原因を特定するには、どのような戦略を使用できますか?
編集:
export LC_ALL=C (or LC_NUMERIC=C); ./a.out
私の問題を解決するようです