与作业混淆.. infile [英] Confusion with homework .. infile

查看:66
本文介绍了与作业混淆.. infile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以到目前为止,我有这个:


#define MAXBOOKS 9

ifstream infile(" library.txt");

struct Book

{

title [MAXBOOKS]

}

while(true)

{

for(int i = 0; i< MAXBOOKS; i ++)

{

char tempTitle [ MAXBOOKS];

infile.getline(book.title,MAXLENGTH);

}

}


我也有主要功能,但我的问题是getline。我的问题是如何让book.title进入标题[0]。

如果我试图通过设置book.title [0] = book.title来声明它,我会上来显然有一个错误..但我怎么把infile变成book.title [0] ????

So with infile I have this so far:

#define MAXBOOKS 9
ifstream infile("library.txt");
struct Book
{
title[MAXBOOKS]
}
while(true)
{
for(int i = 0; i < MAXBOOKS; i++)
{
char tempTitle[MAXBOOKS];
infile.getline(book.title, MAXLENGTH);
}
}

I also have the main function, but my question is with the getline. My problem is how do i get the book.title to go into the title[0].
if i try to declare it by setting book.title[0] = book.title, I come up with an error obviously.. but how do i get the infile into book.title[0]????

推荐答案

展开 | 选择 | Wrap | 行号


如果我带来一本书的名字,那会有用吗? 化学原理,或者我必须使用二维数组????
Will that work if i am bringing in a a name of a book ex. "Principles of Chemistry", or will i have to use a 2d array ????


这是一个测试


这篇关于与作业混淆.. infile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆