0

有人可以帮助或指出我正确的方向吗?

我正在尝试从 .txt 文件中读取 16 个数字(全为 1 和 0)并将每个数字存储到一个数组中。这是我目前正在尝试的

char a[16], b[16] = { 0 };
char c = 0;
ifstream indat;
indat.open("test.txt");
for (int i = 0; i != 16; i++)
    {
    // cout << "enter nums";
    indat.get(c);
    a[i] = c;
    }
indat.close();
for (int i = 0; i != 16; i++)
    cout << a[i] << endl;
system("pause");

我在 1110100111010110 中尝试阅读的示例

我在控制台中得到了一堆随机的废话打印

4

0 回答 0