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->下面的地址栏选择项目地址。

相关推荐
小葡萄202543 分钟前
黑马程序员C++2024新版笔记 第三章 数组
笔记·算法·c++20
勇闯逆流河7 小时前
【数据结构】堆
c语言·数据结构·算法
pystraf8 小时前
LG P9844 [ICPC 2021 Nanjing R] Paimon Segment Tree Solution
数据结构·c++·算法·线段树·洛谷
飞川撸码9 小时前
【LeetCode 热题100】739:每日温度(详细解析)(Go语言版)
算法·leetcode·golang
yuhao__z9 小时前
代码随想录算法训练营第六十六天| 图论11—卡码网97. 小明逛公园,127. 骑士的攻击
算法
Echo``9 小时前
3:OpenCV—视频播放
图像处理·人工智能·opencv·算法·机器学习·视觉检测·音视频
Nobkins9 小时前
2021ICPC四川省赛个人补题ABDHKLM
开发语言·数据结构·c++·算法·图论
88号技师9 小时前
2025年6月一区SCI-不实野燕麦优化算法Animated Oat Optimization-附Matlab免费代码
开发语言·算法·matlab·优化算法
ysy164806723910 小时前
03算法学习_977、有序数组的平方
学习·算法
codists11 小时前
《算法导论(第4版)》阅读笔记:p83-p85
算法