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

相关推荐
星辰即远方18 分钟前
计算器仿写总结
学习·ui·ios·cocoa·xcode
2601_957174651 小时前
大模型算法 简单 容易 用这个方法
算法
VALENIAN瓦伦尼安教学设备1 小时前
激光对中仪采购要点
数据库·嵌入式硬件·算法
Forever Nore3 小时前
LeetCode 1 两数之和
算法·leetcode·职场和发展
To_OC3 小时前
LC 3 无重复字符的最长子串:从入门滑动窗口到优化写法,再也不怕面试官追问
javascript·算法·leetcode
(Charon)4 小时前
【C++】多线程死锁:产生原因、复现与解决方法
开发语言·c++·算法
lucas_AI4 小时前
ConfBench:大模型的「我很有把握」,到底能不能信?
人工智能·算法
oier_Asad.Chen4 小时前
【洛谷题解/AcWing题解/真题】洛谷P2330【SCOI2005】繁忙的都市(Kruskal算法的再探究))
c++·算法·贪心算法·图论·最小生成树·kruskal
青 春 记 忆7 小时前
LeetCode 53. 最大子数组和|Python 解法详解
python·算法·leetcode
豆瓣鸡7 小时前
算法日记 - Day10
算法