Mac上的CodeBlocks没有读取文件

CodeBlocks on Mac are not reading file

本文关键字:读取 文件 上的 CodeBlocks Mac      更新时间:2023-10-16
#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的新手。我更改了"执行工作目录",但它仍然不起作用,请帮助。

不要更改执行工作目录。

// this is your file.txt location
ifstream file("C:\Desktop\file.txt"); // this is for Windows

然后运行一个程序。如果仍然不起作用,请尝试观看本教程:https://www.youtube.com/watch?v=de6try8fryy