WriteOutputValue in C++
WriteOutputValue in C++
以下内容适用于写入字符串数据,但我需要double以及要写入的浮点数据。
我该怎么做?
bool WriteOutputValue( tstring strValue)
{
FILE* pOutputFile = NULL;
// Open file
//_tfopen_s(&pOutputFile, _T("Subtract.txt"), _T("w, ccs=UNICODE") );
_tfopen_s(&pOutputFile, _T("GetBalanceTimeReport.txt"), _T("w") );
if (NULL == pOutputFile)
{
printf("error Output filen");
return false;
}
int nRet = _fputts( strValue.c_str(), pOutputFile);
if (nRet < 0)
{
printf("error writing GetBalanceTimeReportn");
fclose(pOutputFile);
return false;
}
fclose(pOutputFile);
return true;
}
如果您想将doubles、int等输出到文件流,您要查找的函数是fprintf。http://www.cplusplus.com/reference/cstdio/fprintf/
示例:
fprintf(pOutputFile,"%d%d-f",myint1,myint2,mydouble)
相关文章:
- netcat command in c++
- Difference in displaying cv2 Mat
- C++ MFC Libraries in Travis CI
- 如何在OpenSSL中从configuration.h.in获取configuration.h
- 创建具有 new in 函数和"this is nullptr"异常的对象
- IN, OUT, INOUT Parameters
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 有人安装"IITB Simplecpp in mac"吗?
- 从 C 样式字符串中删除子字符串 "in place" 在C++代码中
- 如何修复"error: ‘_1’ was not declared in this scope"?
- Softmax Implementation in C++
- 将 out/in out 参数与 if/switch 的 init 语句一起使用
- IF-nesting in c++
- Gurobi GRBModel and GRBmodel in C++
- Tensorflow Hub in C++
- Centos7 g++ "to_string is not in a member of std"
- InitializeCriticalSectionEx Not Located In KERNEL32.Dll
- 将 lambda 表达式传递给 std::function in C++
- @CPPFLAGS@在 Makefile.in 中意味着什么?
- std::async from std::async in windows xp