void ReadTheData(ifstream& in_stream, ofstream& out_stream)
{
using namespace std;
int id;
char name[100] = "";
double balance;
in_stream >> id >> name >> balance;
while(name[0] || ! in_stream.eof()) // Continue looping until eof or name is not present.
{
cout << id << '\t' << name << '\t' << balance << endl;
in_stream >> id >> name >> balance;
}
}
the Balance.txt has format style:
4248749 Kelly_E 460.02
8898693 Kelly_George_MD 1764.68
4597789 Lambert_Richard 1571.79
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,文件Balance.txt中的最后一行进入无限循环,如何停止无限循环?
这是两行代码:
int (*parry)[10] = &arr // Line # 1
int *(&arrRef)[10] = ptrs // Line # 2
Run Code Online (Sandbox Code Playgroud)
第1行:
parry是一个指向int大小为10 的数组的指针.
它是否意味着:
parray[1]指向的地址arr,parray[2] 要点的 arr parray[10]要点或arr?我Line # 1什么时候用?
解:
#include <iostream>
int main(
{
int arr[10] = { 3, 54 };
int (*parry)[10] = &arr;
std::cout << (*parry)[0] << " " << (*parry)[1] << " " << (*parry)[3] << " " << parry[4] << std::endl;
return …Run Code Online (Sandbox Code Playgroud)