在哪里放置文件为了阅读? [英] Where to place file in order to read?

查看:124
本文介绍了在哪里放置文件为了阅读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我在哪里放置一个我想用fstream阅读的文本文件?在本教程中, http://www.gamedev.net/reference/articles/article1127.asp ,他们说

Hey, where do I place a text file that I'm trying to read using fstream? In this tutorial, http://www.gamedev.net/reference/articles/article1127.asp, they say

ifstream fin(input.txt);

ifstream fin("input.txt");

input.txt?之前,我试图通过这样做C:\Users\XXXXXXX\Documents\test.in指向文件的路径。但这似乎不起作用, http://stackoverflow.com/questions/3095339/incorrect- data-input-with-fstream

where would "input.txt" be located? Before I tried directing a path to the file by doing this "C:\Users\XXXXXXX\Documents\test.in". This however does not seem to work, http://stackoverflow.com/questions/3095339/incorrect-data-input-with-fstream.

我使用CodeBlocks。

I'm using CodeBlocks.

提前感谢。

推荐答案

input.txt工作目录。通常工作目录是包含可执行文件的目录。在Visual Studio的情况下,在调试器中运行时的工作目录可以在调试选项中设置。

input.txt should be in the working directory. Usually the working directory is the directory containing the executable. In the case of Visual Studio, the working directory when run in the debugger can be set in the Debug options.

这篇关于在哪里放置文件为了阅读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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