C ++程序在Xcode不使用outFile输出简单的文本文件 [英] C++ Program in Xcode not outputting simple text file using outFile

查看:313
本文介绍了C ++程序在Xcode不使用outFile输出简单的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个程序使用这个简单的示例代码来输出一个文本文件。我使用Xcode和简单地从命令行工具启动一个新的C ++项目。由于某种原因,程序不会输出任何文件到我的Mac。请帮助找出为什么XCode不会输出任何文件到我的电脑?谢谢!

I am running a program using this simple example code to output a text file. I am using Xcode and simply started a new C++ project from command line tools. For some reason the program does not output any file onto my Mac. Please help figure out why XCode will not output any file to my computer? Thanks!

#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();
}


推荐答案

我想出来了,这是一个选项在Xcode。所以我点击停止按钮旁边的xcode顶部的栏,文本(项目名称>我的Mac 64位)

Dang I can't believe I figured it out, it was an option in Xcode. So I clicked on the bar at the top of xcode near the stop button with the text (Project Name > My Mac 64-bit)

然后点击编辑方案。单击选项选项卡并单击使用自定义工作目录。然后选择了一个工作目录。现在文本文件出现!

Then clicked edit scheme. The clicked on the options tab and clicked use custom working directory. Then selected a working directory. Now the text file appears!

这篇关于C ++程序在Xcode不使用outFile输出简单的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆