我在从文件中读取特定数据时遇到了一些问题。该文件的第一行和第二行有 80 个字符,第三行有未知数量的字符。以下是我的代码:
int main(){
ifstream myfile;
char strings[80];
myfile.open("test.txt");
/*reads first line of file into strings*/
cout << "Name: " << strings << endl;
/*reads second line of file into strings*/
cout << "Address: " << strings << endl;
/*reads third line of file into strings*/
cout << "Handphone: " << strings << endl;
}
我如何执行评论中的操作?