Mac 上的代码块未读取文件
CodeBlocks on Mac are not reading file
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int A;
ifstream file("file.txt"); // there is a single "8" in the file
file >> A;
cout << A; // I get 0 always
return 0;
}
虽然我不是 CodeBlocks 的新手,但我是 Mac 上的 CodeBlocks 新手。我改了"Execution working directory"还是不行,请帮忙
不要更改执行工作目录。当您从文件中读取时,请尝试写入该文件所在的完整目录,例如:
// this is your file.txt location
ifstream file("C:\Desktop\file.txt"); // this is for Windows
然后是运行一个程序。
如果还是不行,试试看这个教程:https://www.youtube.com/watch?v=De6trY8FRYY
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int A;
ifstream file("file.txt"); // there is a single "8" in the file
file >> A;
cout << A; // I get 0 always
return 0;
}
虽然我不是 CodeBlocks 的新手,但我是 Mac 上的 CodeBlocks 新手。我改了"Execution working directory"还是不行,请帮忙
不要更改执行工作目录。当您从文件中读取时,请尝试写入该文件所在的完整目录,例如:
// this is your file.txt location
ifstream file("C:\Desktop\file.txt"); // this is for Windows
然后是运行一个程序。 如果还是不行,试试看这个教程:https://www.youtube.com/watch?v=De6trY8FRYY