I have an error

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

73 Replies - 4038 Views - Last Post: 07 July 2012 - 11:30 AM Rate Topic: -----

#1 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

I have an error

Posted 06 July 2012 - 12:21 PM

it is included in the attachments.
 
    #include <iostream>
    #include <fstream>
    #include <string>


    using namespace std;

	#ifdef __GNUC__ 
	#include <unistd.h>
	#elif defined _WIN32
	#include <cstdlib>
	#endif 
	
    int main () {
	
	
    string Name;
	int SSN;
	int Birth;
	int employmentyr;
	int monthsalary;
	string jobtitle;

	int year;
	int social;
	int age;
	int employ;
	int newsalary;
	int bonus; 
	char yesNo = 'n' ; 
    
	
	
	ifstream fin;
	
	//cout << "Calculate? " ; 
	//cin >> yesNo ;
	//cin.ignore (1000,10);
	//if (yesNo == 'n' ) break ;
	string file;
	cout << "Enter your file: " ;
	cin >> file;
	fin.ignore (1000,10) ; 
	
	fin.open (file);
	if (!fin.good()) throw "I/O error";
	
	fin >> Name;
	cout << "Welcome " << Name << endl;
	fin.ignore (1000,10) ; 
	
	fin >> SSN; 
	
	cin >> social;
	fin.ignore (1000,10) ;
	
	fin >> Birth;
	age = 2012 - Birth; 
	cout << "Your age is: " << age << endl;
	fin.ignore (1000, 10) ;
	
	fin >> employmentyr;
	employ = 2012 - employmentyr;
	cout << "You have been employed for "<< employ << " years" << endl;
	fin.ignore (1000, 10);
    
	fin >> monthsalary;
	year = monthsalary * 12;
	newsalary = year + (year * 0.10) ;
	
	if (age > 31){ //or (employ > 3) ;
	    cout << "Your yearly salary is: " << newsalary << endl;
	}
	
	if (age < 30 ){ //or (employ < 3);
	    cout << "Your yearly salary is: " << year << endl;
	}
	fin >> jobtitle;
	
	bonus = newsalary - year; 
    
	fin.close ();
	
	ofstream fout; 
	fin.eof;
	fout.open ("ReportFile.txt"); 
	if (!fout.good()) throw "I/O error" ;
	fout << setw(10) << "Your Job: ";
	fout << setw(10) <<"Your Yearly Salary: ";
	fout << cout <<setw(10) <<"Name: ";
	fout << setw(10) << "SSN: ";
	fout << setw(10) << "Bonus Salary: " ;
	fout << jobtitle << endl;
	fout << newsalary << endl;
	fout << Name << endl; 
	fout << SSN << endl;
	fout << bonus ; 
	fout.flush(); 
	
	fout.close (); 
	#ifdef __GNUC__
	sleep (1);
	#elif defined _WIN32
	_sleep (1000);
	#endif 
	



	  return 0; 
	  } 



Is This A Good Question/Topic? 0
  • +

Replies To: I have an error

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: I have an error

Posted 06 July 2012 - 12:22 PM

Please use a descriptive title. Also, again, there is no attachment. Without your errors, we cannot help you.
Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg  Icon User is online

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,737
  • Joined: 25-December 09

Re: I have an error

Posted 06 July 2012 - 12:28 PM

Cut and paste your complete error messages, exactly as they appear in your development environment, into your post, don't try to post a picture. The pictures are usually too hard to read.

Also find a indentation style you like and use it consistently. The way your code is presently formatted makes your program very difficult to read.

Jim

This post has been edited by jimblumberg: 06 July 2012 - 12:29 PM

Was This Post Helpful? 0
  • +
  • -

#4 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 12:30 PM

http://i45.tinypic.com/353eae8.png



ther?

sorry if im pissing you off
Was This Post Helpful? 0
  • +
  • -

#5 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 12:43 PM

should i make another topic then?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3165
  • View blog
  • Posts: 9,559
  • Joined: 05-May 12

Re: I have an error

Posted 06 July 2012 - 12:44 PM

The code you pasted does not correspond with the screenshot of the error. You could have as easily done a Right Click.Mark, and done a copy and paste here into the forum. Typically, screenshots are harder to read.

Anyway, the main problem is that on line 85 of the code you posted, there is no '()' after feof.

Another problem you'll find is that you are using setw() and other functions that are in <iomanip>, but you aren't including the header file.
Was This Post Helpful? 1
  • +
  • -

#7 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 12:57 PM

sorry but whats a header file?

so would it be
fin.feof;
?
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3165
  • View blog
  • Posts: 9,559
  • Joined: 05-May 12

Re: I have an error

Posted 06 July 2012 - 12:58 PM

View Postsharkbowman, on 06 July 2012 - 12:53 PM, said:

sorry but whats a header file?


If you don't know what a header file is, why do you have lines 1-3, 9, and 11? Are they there just for decoration?
Was This Post Helpful? 2
  • +
  • -

#9 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 01:07 PM

o those ones. i just didnt know the names of them

so i dont have the correct header files?

\Users\Patrick Nguyen\Desktop>cl "C:\Users\Patrick Nguyen\De
cpp"
crosoft ® 32-bit C/C++ Optimizing Compiler Version 16.00.3
pyright © Microsoft Corporation. All rights reserved.

lary - Copy.cpp
\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE
ing C4530: C++ exception handler used, but unwind semantics
cify /EHsc
\Users\Patrick Nguyen\Desktop\Salary - Copy.cpp(44) : error
e::eof': function call missing argument list; use '&std::ios
e a pointer to member
\Users\Patrick Nguyen\Desktop\Salary - Copy.cpp(44) : fatal
to recover from previous error(s); stopping compilation

\Users\Patrick Nguyen\Desktop>

that is the errors that i get from it
Was This Post Helpful? 0
  • +
  • -

#10 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 01:14 PM

sorry i did it wrong......
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3165
  • View blog
  • Posts: 9,559
  • Joined: 05-May 12

Re: I have an error

Posted 06 July 2012 - 01:15 PM

You need to fix the problem with the line with feof first, then you'll see the next set of errors. When you see those errors, you can fix them by adding <iomanip> to headers that you include.

Additionally, you should add "/EHsc" to your compile options.
Was This Post Helpful? 1
  • +
  • -

#12 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 01:18 PM

 
    #include <iostream>
    #include <fstream>
    #include <string>


    using namespace std;

	
    int main () {

	ifstream fin;

	
    string Name;
	int SSN;
	int Birth;
	int employmentyr;
	int monthsalary;
	string jobtitle;

	int year;
	int social;
	int age;
	int employ;
	int newsalary;
	int bonus; 
	char yesNo = 'n' ; 
    
	
	

	
	//cout << "Calculate? " ; 
	//cin >> yesNo ;
	//cin.ignore (1000,10);
	//if (yesNo == 'n' ) break ;
	string file;
	cout << "Enter your file: " ;
	cin >> file;
	fin.ignore (1000,10) ; 
	
	fin.open (file);
	while (fin.eof);
	//if (!fin.good()) throw "I/O error";
	
	fin >> Name;

	
	fin >> SSN; 
	
	
	fin >> Birth;
	age = 2012 - Birth; 
	
	fin >> employmentyr;
	employ = 2012 - employmentyr;
    
	fin >> monthsalary;
	year = monthsalary * 12;
	newsalary = year + (year * 0.10) ;
	bonus = newsalary - year ; 
	
	if (age > 31){ //or (employ > 3) ;
	
	}
	
	if (age < 30 ){ //or (employ < 3);
	    
	}
	fin >> jobtitle;
	
	bonus = newsalary - year; 
    
	fin.close ();
	
	ofstream fout; 
	fout.open ("ReportFile.txt"); 
	if (!fout.good()) throw "I/O error" ;
      fout << "---|Job Title|-" << "-|Yearly Salary|-" << "-|Yearly Bonus|-" << "-|  Name  |-" << "--------|SSN|--" << endl;
	  fout << "---------------------------------------------------------------------------" << endl;
	  fout <<"    " <<jobtitle << "      " << year << "            " << bonus << "           " <<  Name << "      " << SSN << "    " <<  endl;
	
	fout.close (); 

	



	  return 0; 
	  } 



thers the correct code.... sorry that i wasted your time on the other
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: I have an error

Posted 06 July 2012 - 01:21 PM

Thanks for sharing your solution! :)
Was This Post Helpful? 0
  • +
  • -

#14 sharkbowman  Icon User is offline

  • D.I.C Head

Reputation: -13
  • View blog
  • Posts: 147
  • Joined: 06-July 12

Re: I have an error

Posted 06 July 2012 - 01:23 PM

solution?
Was This Post Helpful? 0
  • +
  • -

#15 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: I have an error

Posted 06 July 2012 - 01:33 PM

Your corrected code.
Was This Post Helpful? 0
  • +
  • -

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »