Hi guys :)
Thanks first for the help, yesterday.. I really did well in my exam :), thanks a lot again :)
Well, I guess I need a little bit help in this
I have a file, and I want the whole paragraph in the file to be inserted in the LinkList, How can I do it?
This is my code *I'll explain what I did below it*
//######################## Begin Function Main ###########################
int main()
{
string lib;
LinkList game;
cout << "Please, Read the paragraph Carefully.\nAfter the you'll have to fill the suitable word in the suitable place.\n";
cout << "For example, for each Keyword; name, adverb..etc, Fill in the suitable word.\n\n\n";
// Ofstream constructor opens file
ifstream fin( "madlib.txt" );
// exit program if the file not opened
if( !fin )
{
cerr << "File couldn't be opened.\n";
exit(1);
} // end if statement
while( getline( fin, lib, '\n' ) )
{
game.insert( lib );
cout << lib;
} // end while loop
cout << endl;
return 0;
}
//######################## End Function Main ###########################
Well, first of all I called the file, and I input the data so that It'll output on the screen
then I tried to add this function *game.insert( lib )* I passes it to the LinkList as a Char, but it didn't worked!! and is that right what I did to pass it as a Character?
the compiler said
*error C2664: 'insert' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char*
Well, how I can insert the paragraph in the text file to my LinkList class?
thanks in advance, sorry for taking from your time :)