Xcode输出到文件失效

cpp 复制代码
#include <iostream>
#include <fstream>

using namespace std;

int main() {
double myNumber = 42.5;
fstream outfile("test.txt", fstream::out);
outfile << "The answer is almost " << myNumber << endl;
outfile.close();
}

运行之后未能找到相应的test.txt文件

解决:

选择顶栏中的Product->Scheme->Edit Scheme->Options->Working Directory勾选Use custom working directory->下面的地址栏选择项目地址。

相关推荐
shehuiyuelaiyuehao33 分钟前
算法50,分治归并,数组中的逆序对
java·算法
阳明山水1 小时前
校准分位数驱动智能库存决策
人工智能·深度学习·算法·机器学习·架构
别动我齐刘海2 小时前
ROS2 Jazzy + C++ 实战路线——进阶学习3
c++·人工智能·vscode·python·算法·机器学习·机器人
zhangfeng11332 小时前
《从“人工适配“到“智能生成“:KernelSwift 跨国产芯片算子迁移全栈方案解读》 —— 强调范式跃迁和跨硬件属性,适合偏架构分析的写法
人工智能·算法·华为·ai编程·npu
0+1113 小时前
算法 --滑动窗口
c++·算法·leetcode
reikocao3 小时前
大场景下 Hessian 特征值放大与退化检测
算法
hetao17338373 小时前
2026-09-18 hetao1733837 的刷题记录
c++·算法
wuyk5554 小时前
21.计数排序:不用比较的“空间换时间”排序算法
python·算法·排序算法