0

here is code[

#include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
struct book_dtail
{
	int copies;
	char title[50];
	char author[50];
	int year;
	char **bn;
};
void main()
{
	int size;
	ifstream indata;
	book_dtail user_book[5];
	indata.open("file path to be added here");
	for(int count=0;count<5;count++)
	{
		indata>>size;
		user_book[count].copies=size;//2D array initialized.
		user_book[count].bn=new char*[size];
		for(int temp=0;temp<size;temp++)
		{
			user_book[count].bn[temp]=new char[4];
		}
		indata.getline(user_book[count].title,50);
		indata.getline(user_book[count].author,50);
		indata>>user_book[count].year;
		for(int temp=0;temp<size;temp++)
		{
			indata.getline(user_book[count].bn[temp][4],50);//(error in this line)"error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::getline(_Elem *,std::streamsize)' : cannot convert parameter 1 from 'char' to 'char *'"
		}
	}
}

]
//i dont know cause of error , nd also how to remove it

Edited by WaltP: Added CODE Tags

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by a4aadi
1

user_book[count].bn[temp][4] is a single character. Change it to user_book[count].bn[temp]

Edited by WaltP: n/a

0

thanks so much WaltP..it worked....(it wz stupid mistake :s)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.