ifstream inputfile;
	cout << "enter the name of the file: ";
	cin >> filename;
	inputfile.open(filename);
	string temp;
	int i = 0;

	while(filename != NULL)
	{
		while(isalpha(filename))
		{
			temp[i++] = filename;
		}
		if(i > 0)
		{
			insert(temp, 1);
			i = 0;
		}
	}

this is my code, what am I doing wrong?

I'm creating a linked list(not a part of the question asked), I'm inserting all the words from a file into the list.

am I extracting the word the wrong way? someone please show me the light :)

You're OK till the while loop - what's it supposed to be doing?

How about something like:

if( inputfile ) //file opened, let's do some work
{
   while ( inputfile >> temp ) //gets one word at a time
   {                            //if successful, store the word
           list.insert( temp );
           i++;    //just so you know how many you've inserted
    }
}

Once you've opened the file named in filename, you don't need to use that variable for anything.

isapha( ) takes single characters as its argument, not a string.

Care to share? Sure you got it right?

sure :)

void file(char filename[])
{
	List l;
	ifstream inputfile;
	cout << "enter the name of the file: ";
	cin >> filename;
	inputfile.open(filename);
	char temp[SIZE];
	string temp2;
	
	while(inputfile != NULL)
	{
		inputfile >> temp;
		int i = 0;
		while(temp != NULL)
		{
			temp[i] = tolower(temp[i]);
			i++;
		}
		temp2 = temp;
		l.insert(temp2, 1);
	}
	
}

Sure this is working right?

how about while( temp[i] != NULL ) temp itself will never be NULL in this usage.

Comments
showed me the light on writing datas to array

Sure this is working right?

how about while( temp[i] != NULL ) temp itself will never be NULL in this usage.

thank you!! I was wondering why my program kept crashing.

This article has been dead for over six months. Start a new discussion instead.