Thread: Windows isn't liking this, neither is dos

  1. #1
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110

    Windows isn't liking this, neither is dos

    I got this code from gametutorials.com, I had to modify it for my complier (its tutorial about file reading #2), sometimes windows will read it, but it will give invalid assignemnt errors most of the time.

    Code:
    #include <iostream.h> 
    #include <string.h> 
    #include <fstream.h>
    
    int main()
    {
    	ifstream file_in("GT.txt");
    
    		if(!file_in)
    			return 1; 
    
    	char a_word[10];
    
    	while(!file_in.eof())
    	{
    		file_in >> a_word; // Here we read in a "word"
    
    		if (strcmp(a_word,"\n")==0)
    		cout << "\n";
    
    		else
    		cout << a_word; 
    
    		cout << " "; 
    	}
    
    	file_in.close();
    
    	return 0;
    }
    GT.txt :
    This tutorial was brought to by GameTutorials. \n
    Testing line 2.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Away.

  3. #3
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    k, it doesn't like this way either:

    Code:
    while(strcmp(a_word,"<10>")!=0)
    note: i ended the gt.txt with a <10>, and I only changed the while, it gives the same error

    Edit> editing the text file, I managed to get the program to work, however, it repeats the contents of the file twice, and it doesn't accept periods in the file.

    Edit2> k, I got it working
    Last edited by Dark Nemesis; 08-15-2003 at 06:52 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning Dos and learning Windows
    By blankstare77 in forum C++ Programming
    Replies: 8
    Last Post: 07-31-2005, 03:48 PM
  2. getting to true DOS with windows NT
    By major_small in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-05-2003, 05:23 PM
  3. real mode dos & win dos
    By scott27349 in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 08-19-2002, 06:15 AM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM
  5. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM