fatal error C1001

This is a discussion on fatal error C1001 within the C++ Programming forums, part of the General Programming Boards category; I am getting an error: cpp1.cpp(18) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1794) I think ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    13

    fatal error C1001

    I am getting an error:

    cpp1.cpp(18) : fatal error C1001: INTERNAL COMPILER ERROR
    (compiler file 'msc1.cpp', line 1794)

    I think this may have something to do with my header files, but they are included correctly.

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <ctype.h>
    #include <iomanip.h>
    #include "student.h"
    #include "StudentLinkList.h"
    
    //Main function
    
    int main(void)    //This is line 18
    {
    	char cmd;
    	do{
    		cout << "Please enter a command: R)ead, L)ist, G)rades, A)dd, D)elete, S)ave, or Q)uit" << endl;
    		cin >> cmd;
    		switch ( cmd = toupper(cmd))
    		{
    		case 'R':
    			s.ReadFile ();
    			break;
    		case 'L':
    			s.List ();
    			break;
    		case 'G':
    			s.Grades ();
    			break;
    		case 'A':
    			s.Add ();
    			break;
    		case 'D':
    			s.Delete ();
    			break;
    		case 'Q':
    			break;
    		case 'S':
    			s.Save ();
    			break;
    		default:
    			cout << "Invalid Command. ";
    		}
    	}while(cmd!='Q');
    	return 0;
    }

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    VC++6 is useless...

    Nothing remarkable here, it's probably something in the headers.

    But you're using the outdated C++ headers.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    There are usually workarounds...

    Let's see your student.h and StudentLinkList.h.

    And avoid using globals, "s", unless you really need them.

    gg

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    Student.h file

    Code:
    #ifndef STUDENT_H
    #define STUDENT_H
    #include <iostream.h>
    #include "str.h"
    
    
    class Student{
    	Str name;
    	int grade;
    public:
    	Student(char *n="", int g=0);
    	friend istream &operator >> (istream &in, Student &student);
    	friend ostream &operator << (ostream &out, Student &student);
    	friend class StudentList;
    };
    
    class StudentList{
    	Student *p;
    	int count;
    public:
    	StudentList (int n=20);
    	~StudentList();
    	void ReadFile();
    	void Sortbyname();
    	void Sortbygrade();
    	void List();
    	void Grades();
    	void Add();
    	void Delete();
    	void Save();
    
    };
    
    #endif
    StudentLinkList.h file

    Code:
    #ifndef STUDENTLINKLIST_H
    #define STUDENTLINKLIST_H
    #include "student.h"
    #include <iostream.h>
    #include <fstream.h>
    typedef class StudentNode * PStudentNode;
    
    class StudentNode{
    	Student s;
    	PStudentNode next;
    public:
    	StudentNode (char *p="", int grade=0);
    	friend istream & operator >> (istream&, StudentNode&);
    	friend ostream & operator << (ostream&, StudentNode&);
    	friend class StudentLinkList;
    };
    
    class StudentLinkList{
    	PStudentNode top;
    public:
    	StudentLinkList();
    	~StudentLinkList();
    	void ReadFile();
    	void List();
    	void Insert (PStudentNode);
    	void Delete ();
    	void Sortbygrade ();
    	void Grades();
    	void Save ();
    };
    #endif;

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    Now str.h - and anything else I need to compile (code wise).

    gg

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    str.h file:

    Code:
    #ifndef STR_H
    #define STR_H
    #include <iostream.h>
    #include <string.h>
    
    
    
    class Str {													//create class 'str'
    	char s[32];												//define array of 32 characters
    public:
    	Str (char *p="");										//ctor (default)
    	int operator<(Str &str);								//operator 
    	int operator==(Str &str);
    	friend istream & operator>>(istream &in, Str &str);
    	friend ostream & operator<<(ostream &out, Str &str);
    };
    #endif
    StudentLinkList.cpp:
    Code:
    #include "StudentLinkList.h"
    #include <iomanip.h>
    #include <iostream.h>
    #include <fstream.h>
    #include <ctype.h>
    #include <iomanip.h>
    
    StudentNode::StudentNode (char *p, int grade) :s(p,grade) {	next=NULL;}
    
    istream &operator >> (istream &in, StudentNode &s){
    	in >> s.s;
    	return in;
    }
    
    StudentLinkList::StudentLinkList(){
    	top=NULL;
    }
    
    StudentLinkList::~StudentLinkList(){
    	while (top!=NULL)
    	{
    		PStudentNode p=top;
    		top=top -> next;
    		delete p;
    	}
    }
    
    void StudentLinkList::List(){
    	PStudentNode curr=top;
    	while (curr!=NULL)
    	{
    		cout << curr->s << endl;
    		curr = curr->next;
    	}
    }
    
    void StudentLinkList::ReadFile(){
    	ifstream infile;
    	char fn[64];
    	cout <<"Enter the file name:";
    	infile.open (fn,ios::nocreate);
    	if (infile)
    	{
    		while (!infile.eof())
    		{
    			PStudentNode p=new StudentNode;
    			infile >> *p;
    			Insert (p);
    		}
    		infile.close();
    	}
    }
    
    void StudentLinkList::Insert (PStudentNode NewNode){
    	if (top==NULL) top=NewNode;
    	else if (NewNode->s.Name() < top->s.Name() )
    	{
    		NewNode ->next = top;
    		top = NewNode;
    	}
    	else
    	{
    		PStudentNode curr = top, prev;
    		while (curr !=NULL && curr->Name() < NewNode->s.Name() )
    		{
    			prev = curr;
    			curr = curr->next;
    		}
    		prev->next = NewNode;
    		NewNode -> next = curr;
    	}
    }
    
    void StudentLinkList::Delete (str name){
    	{
    		if (top->Name==name)
    		{
    			PStudentNode tmp=top;
    			top = top->next;
    			delete tmp;
    		}
    		else
    		{
    			PStudentNode curr=top,prev;
    			while(curr!=NULL && curr->name != name)
    			{
    				prev=curr;
    				curr=curr -> next;
    			}
    			if(curr !=NULL)
    			{
    				prev->next = curr->next;
    				delete curr;
    			}
    		}
    	}
    }

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    First thing I get is:
    >> error C2065: 's' : undeclared identifier
    So atleast you're not using globals

    The first thing you need to do is make sure your compiler is up-to-date with any patches or service packs. If you are running VC++ 6.0 (as it seems) them you should apply service pack 6 for that product:
    http://msdn.microsoft.com/vstudio/do...6/default.aspx

    Once the compiler stops blowing up, you should be on your way to resolving issues in your code. Although now that your code is here for the world see, you might get some constructive criticism while you're waiting for SP6 to download

    gg

  8. #8
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    I don't see how that's possible. I do have SP6, and just for giggles I reinstalled it. I am getting the same error.

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    >> int main(void) //This is line 18
    That's line 10 for me - have you shown all your code?

    Zip up your project and source files (*.dsp, *.dsw, *.cpp, *.h) and attach it to the thread.

    gg

  10. #10
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    I had just removed some commented lines required by my instructor.

    I will attach the files.

  11. #11
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    Here it is
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    just for kicks and something quick and easy to try:

    make this:

    int main(void)

    this:

    int main()

    and add this:

    StudentLinkList s;

    in main before the switch statement somewhere.

    Also, I suggest you stop using s as the variable name for everything. The more s's you have as variables, the harder it is to keep which scope each s has.

  13. #13
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    Still no blow-up. Here's what I would try:
    - uninstall Visual Studio
    - hit windows update and get the OS up-to-date
    - re-install Visual Studio
    - re-apply SP6

    In the mean time:
    Code:
    Compiling...
    StudentLinkList.cpp
    studentlinklist.cpp(56) : error C2039: 'Name' : is not a member of 'Student'
            student.h(11) : see declaration of 'Student'
    studentlinklist.cpp(56) : error C2039: 'Name' : is not a member of 'Student'
            student.h(11) : see declaration of 'Student'
    studentlinklist.cpp(64) : error C2039: 'Name' : is not a member of 'StudentNode'
            studentlinklist.h(8) : see declaration of 'StudentNode'
    studentlinklist.cpp(64) : error C2039: 'Name' : is not a member of 'Student'
            student.h(11) : see declaration of 'Student'
    studentlinklist.cpp(64) : fatal error C1903: unable to recover from previous error(s); stopping compilation
    Error executing cl.exe.
    
    StudentLinkList.obj - 5 error(s), 0 warning(s)
    Code:
    Compiling...
    Cpp1.cpp
    cpp1.cpp(27) : error C2065: 's' : undeclared identifier
    cpp1.cpp(27) : error C2228: left of '.ReadFile' must have class/struct/union type
    cpp1.cpp(30) : error C2228: left of '.List' must have class/struct/union type
    cpp1.cpp(33) : error C2228: left of '.Grades' must have class/struct/union type
    cpp1.cpp(36) : error C2228: left of '.Add' must have class/struct/union type
    cpp1.cpp(39) : error C2228: left of '.Delete' must have class/struct/union type
    cpp1.cpp(44) : error C2228: left of '.Save' must have class/struct/union type
    Error executing cl.exe.
    
    Cpp1.obj - 7 error(s), 0 warning(s)
    gg
    Last edited by Codeplug; 10-14-2004 at 12:11 PM.

  14. #14
    Registered User
    Join Date
    Aug 2004
    Posts
    13
    Hmm, well thank you for your help on this. I honestly don't know why I am getting this error.. Windows XP SP2, perhaps?

  15. #15
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    If so, it wouldn't be the first problem with SP2 that I've heard of

    gg

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fatal error in fprintf
    By shoobsie in forum C Programming
    Replies: 4
    Last Post: 10-14-2005, 06:56 AM
  2. Fatal errors
    By cheeisme123 in forum C++ Programming
    Replies: 2
    Last Post: 02-06-2003, 10:03 PM
  3. Weird fatal error, header file related
    By alkis_y3k in forum C++ Programming
    Replies: 2
    Last Post: 12-26-2002, 09:54 AM
  4. fatal exception 0E
    By juhigarg in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2001, 04:40 AM
  5. Fatal error :/
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-13-2001, 08:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21