Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 读取加密到xcode_C++_Xcode - Fatal编程技术网

C++ 读取加密到xcode

C++ 读取加密到xcode,c++,xcode,C++,Xcode,如何从调用数据的文件中读取x值 我将文件放在程序文件中,但保留给我的 找不到文件 #include <iostream> #include <cstdlib> #include <fstream> #include <string> using namespace std; double const NUMB=10; int main () { double x; ifstream infile; infile.open("da

如何从调用数据的文件中读取x值

我将文件放在程序文件中,但保留给我的

找不到文件

#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>

using namespace std;

double const NUMB=10;



int main ()
{
double x;

  ifstream infile;
  infile.open("data");

  if (!infile.is_open()){
    cout<<"NOT OPEN"<<endl;
    system ("PAUSE");
    exit (1);
  }

  infile >>x;

  while (infile>0){
    cout<<x<<endl;
  infile>>x;
  }

  infile.close();
  return 0;
 }

使用Xcode时,名为data的文件必须放在buildproducts目录中。也就是说,在构建之后,它需要放在Xcode放置可执行文件的同一位置。默认情况下,这不是源代码所在的目录。对于这样的命令行应用程序,最简单的处理方法就是在项目中包含文件数据,然后告诉Xcode在生成文件时将文件复制到buildproducts目录。您可以通过单击项目,然后单击正在构建的目标来执行此操作。在目标设置的顶部进入构建阶段。最后一个阶段应该是复制文件。在“复制文件”中单击+并选择数据文件,只要您将其添加到项目中,数据文件就会被列出。

代码很好,您是否有名为“数据”的文件?您好,是的,我有一个文件调用数据,它放在main所在的文件夹中,但位置不一定正确。这完全取决于您的编译器/平台。在不知道如何构建和运行程序的情况下,很难给出更好的建议。我在mac上运行xcode..我曾经有eclipse,我喜欢它,但一旦我更新了我的系统,eclipse就不再为我工作了