I am a new user on this C and have a hard trouble with I/O's. If you could let me know what I am not clarifying. Thank You!

#include <stdio.h> 
#include <stdlib.h>


// employee structure definition //
struct year2009Data {

	float SSN;				// employee social security number //
	char lastName [25];		// employee last name //
	char firstName [15];	// employee first name //
	int W4with;				// employee elected withholding //
	float hourlywage;		// employee hourly wage //
	float hours;			// employee weekly hours //
	float gross;			// gross wages for week //
	float fedwith;			// federal tax for week //
	float sstax;			// social security tax  for week //
	float medtax;			// medicare tax for week //
	float statetax;			// state tax for week //
	float countytax;		// county tax for week //
	float net;				// net pay for week //
	float ytdgross;			// ytd gross wages // 
	float ytdfedwith;		// ytd federal withholding tax //
	float ytdsstax;			// ytd social security tax //
	float ytdmedtax;		// ytd medicare tax //
	float ytdstatetax;		// ytd state tax //
	float ytdcountytax;		// ytd county tax //
	float ytdnet;			// ytd netpay //
};						// End structure //


void employeeHours (FILE *fPtr);
void editEmployee (FILE *fPtr);
void newEmployee (FILE *fPtr);
void reportFile (FILE *readPtr);

int main (void) 
{

	FILE *cfPtr; // year2009.dat file pointer //
	int choice; // user's choice //
	int employeenum;		// employee number //
	int currentornew;		//current or new employee
	int newemployee;		//new employee format
	int endLoop = 0;		//starting the end loop at 0 so it is not trash
	
	// prompy user for choice //
	 
	while( endLoop == 0) {
		printf(" Welcome to ESLR, LLC \n"
		  "1-Enter Employee Hours \n"
		  "2-Edit Employee Information \n"
		  "3-Add New Employee \n"
		  "4-Creat A Report \n"
		  "5-Exit Program \n"); /*Prompt for input*/
 	
		scanf( "%d", &currentornew);
 		
		if ((currentornew > 5) || (currentornew < 1)){
		
		system("cls");
		
		printf("Invalid entry, please try again.\n\n");
		
	 } //end if statement
 		
		else {
	 
		endLoop = 1;
 
		} //end else statement
	 	
	} //end while statement

		// opens file or exits if file cannot be opened //
	
		if (( cfPtr = fopen("year2009Data.dat", "w+")) == NULL) {
		
		printf ("File could not be opened.\n");
		
		} // end if //


switch ( currentornew ) {

//update employee
case 1:
	employeeHours (cfptr);
	break;
	
	//enter employee hours
case 2:
	editEmployee (cfptr);
	
	break;

	//edit employee information
case 3:

	newEmployee (cfptr);
	
	break;

	//add new employee
case 4:
	reportfile (cptr);
	 //Summary
	break;

case 5:
	

	//Exit the program
default:
	printf( "Incorrect Choice\n");
	break;

 } //succesful programming


}
		fclose (cfPtr); // closes year2009.dat file //
	} // end else //

	return 0; // indicates successful program //
} // end main //

// Edit employee function //

void editEmployee (FILE *fPtr)
{

	int employeenum;
	struct year2009Data Employee = {0};

	// ask user for employee number //
	printf("Enter employee number: ");
	scanf("%d", &employeenum);

	// move file pointer to correct location //
	fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

	// read record from file //
	fread(&employeenum, sizeof( struct year2009Data), 1, fPtr);

	// error displayed if employee number has already been used //
	if (employeenum == 0) {
		printf("Employee number has no information.\n, year2009.employeenum");
	} // end if //

	else { // edit employee information//

		// prompt user for employee information //
		printf("Enter employee social security number: ");
		scanf("%lf", Employee.SSN);
		printf("Enter employee last name: ");
		scanf("%s", Employee.lastName);
		printf("Enter employee first name: ");
		scanf("%s", Employee.firstName);
		printf("Enter value from box XX of employee W4: ");
		scanf("%d", Employee.W4with);
		printf("Enter employee hourly wage: ");
		scanf("%lf", Employee.hourlywage);

		Employee.employeenum = employeenum;

		// move file pointer to correct record in file //
		fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

		// write new data to file //		
		fwrite(&employeenum, sizeof( struct year2009Data), 1, fPtr);
	} // end else //
} // end function editEmployee //

// Update employee hours for week //

void employeeHours (FILE *fPtr)
{
	int employeenum, hours;
	struct year2009Data Employee = {0};

	// obtain employee number to update //
	printf("Enter employee number to update: ");
	scanf("%d", &employeenum);

	// move file pointer to correct location //
	fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

	// read record from file //
	fread(&employeenum, sizeof( struct year2009Data), 1, fPtr);

	// error notice if employee cannot be found //
	if (Employee.employeenum == 0) {
		printf("Employee #%d has no information. \n", employeenum);
	} // end if //

	// update employee record //
	else { 
		printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "employeenum", "SSN", "lastName",
							"firstName", "W4with", "hourlywage", "hours", "gross", "fedwith", "sstax", "medtax",
							"statetax", "countytax", "net", "ytdgross", "ytdfedwith", "ytdsstax", "ytdmedtax",
							"ytdstatetax", "ytdcountytax", "ytdnet");

		// request hours //
		printf("Please input hours for the week:");
		scanf("%lf", &hours);

		// calculate taxes and wages //
		Employee.gross = Employee.hours * Employee.hourlywage;
		Employee.fedwith = Employee.gross * 0.20;
		Employee.sstax = Employee.gross * 0.062;
		Employee.medtax = Employee.gross * 0.0145;
		Employee.statetax = Employee.gross * 0.034;
		Employee.countytax = Employee.gross * 0.044;
		Employee.net = Employee.gross - Employee.fedwith - Employee.sstax - Employee.medtax - Employee.statetax - Employee.countytax;
		Employee.ytdgross = Employee.ytdgross + Employee.gross;
		Employee.ytdfedwith = Employee.ytdfedwith + Employee.fedwith;
		Employee.ytdsstax = Employee.ytdsstax + Employee.sstax;
		Employee.ytdmedtax = Employee.ytdmedtax + Employee.medtax;
		Employee.ytdstatetax = Employee.ytdstatetax + Employee.statetax;
		Employee.ytdcountytax = Employee.ytdcountytax + Employee.countytax;
		Employee.ytdnet = Employee.ytdnet + Employee.net;

		// move file pointer to correct record in file //
		fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

		// write new data to file //		
		fwrite(&employeenum, sizeof( struct year2009Data), 1, fPtr);
	} // end else //
} // end function employeeHours //

// New employee function //

void newEmployee (FILE *fPtr)
{
	FILE *cfPtr; // year2009Data file pointer //

	// create year2009Data with default info //
	struct year2009Data blankEmployee = {0, 000000000, "", ""};

	int employeenum;

	if ((cfPtr = fopen("year2009Data", "a+")) == NULL) {
		printf("File could not be opened.\n");
	} // end if //
	else {

		// ask user for new employee number //
		printf("Enter new employee number: ");
		scanf("%d", &employeenum);
		
		while (blankEmployee.employeenum !=0) {
		// move file pointer to correct location //
		fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

		// read record from file //
		fread(&employeenum, sizeof( struct year2009Data), 1, fPtr);

			// error displayed if employee number has already been used //
			if (blankEmployee.employeenum !=0) {
			printf("Employee number #%d has already been used.\n", blankEmployee.employeenum);
			} // end if //
			else {

				// create new employee //
				// prompt user for employee information //
				printf("Enter employee social security number: ");
				scanf("%lf", &blankEmployee.SSN);
				printf("Enter employee last name: ");
				scanf("%s", &blankEmployee.lastName);
				printf("Enter employee first name: ");
				scanf("%s", &blankEmployee.firstName);
				printf("Enter value from box XX of employee W4: ");
				scanf("%d", &blankEmployee.W4with);
				printf("Enter employee hourly wage: ");
				scanf("%lf", &blankEmployee.hourlywage);

				blankEmployee.employeenum = employeenum;

				// move file pointer to correct record in file //
				fseek(fPtr, (employeenum - 1) * sizeof( struct year2009Data), SEEK_SET);

				// write new data to file //		
				fwrite(&employeenum, sizeof( struct year2009Data), 1, fPtr);
			} // end else //
		} // end while //
	} // end else //
} // end function newEmployee //

// Create .txt file report //

void reportFile (FILE *readPtr)
{
	FILE *writePtr; // year2009.txt file pointer //

	// creates year2009 file structure with blank data //
	struct year2009Data Employee = { 0, 000000000, "", ""};
	
	// fopen opens the file; exits if the file cannot be opened //
	if ((writePtr = fopen("year2009.txt", "r")) == NULL) {
		printf ("File could not be opened.\n");
	} // end if //

	else {
		rewind (readPtr); // sets pointer back to beginning of file //
		fprintf (writePtr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "employeenum", "SSN", "lastName",
							"firstName", "W4with", "hourlywage", "hours", "gross", "fedwith", "sstax", "medtax",
							"statetax", "countytax", "net", "ytdgross", "ytdfedwith", "ytdsstax", "ytdmedtax",
							"ytdstatetax", "ytdcountytax", "ytdnet");

		// copy all files from random-access file to text file //
		while (!feof(readPtr)) {
			fread (&Employee, sizeof( struct year2009Data), 1, readPtr);

			// creates single employee record to file //
			if (Employee.employeenum !=0) {
			fprintf (writePtr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "employeenum", "SSN", "lastName",
							"firstName", "W4with", "hourlywage", "hours", "gross", "fedwith", "sstax", "medtax",
							"statetax", "countytax", "net", "ytdgross", "ytdfedwith", "ytdsstax", "ytdmedtax",
							"ytdstatetax", "ytdcountytax", "ytdnet");
			} // end if //
		} // end while //

	} // end else //
} // end function //

You are going to have to tell us what that program does not do that you want it to do, or what it does wrong. We are not clairvoyant nor are we mind readers.

You are going to have to tell us what that program does not do that you want it to do, or what it does wrong. We are not clairvoyant nor are we mind readers.

Sorry,

The program is suppose to work for a business that has employees. It will calculate hours, create employees, tax breaks, edit employees, and view employees.

For some reason when I compile the program it say I have not clarified my (cfptr) -which is my pointer of where I want to send it-

I also can not open a .dat file, but it wasn't created yet. So am so lost on that information. I tried looking at my book and that is no help what so ever. They show examples, but I have no idea.

>>For some reason when I compile the program it say I have not clarified my (cfptr)

You have to declare variables before they can be used. Check the spelling and capitalization of that variable carefully.

There are a lot of other problems in your program related to misspelling variables names. Try not to be so careless with them because the compiler will scream at you.

About opening the data file. Which function(s) are you referring to?

Thats the thing I can not figure out... Where did I screw up with the undeclared identifier. For all of them it says that I have an undeclared identifier. I looked above and saw that I declared them and I am trying to navigate the pointers to the appropriate spot. I am 100% lost on what has gone wrong. I wish I could give you detail on what is going on, but for the most part I am stumbling hard core and trying to see what is happening. Sorry for being illiterate on this subject. If I didn't answer your question am sorry I don't quite know what you are asking.

did you write this code??

Did you check the spelling and capitalization as I suggested in my previous post ? FILE *cfPtr; and employeeHours (cfptr); -- they are not the same.

all i have to say is that is a lot of code for a new user of C, you should have line numbers on your error messages regarding undeclared variables, go to those line numbers and make sure the variables are spelled correctly... C is case sensitive

all i have to say is that is a lot of code for a new user of C,

BINGO.

that's what i was alluding to when i asked "did you write this code??"

given that he's so helplessly "illiterate" (his word), i'm highly skeptical he wrote very much of that himself. im thinking he begged, borrowed or stole it from someone else.


.

To be fair, it doesn't really matter whether he wrote all that code or not. He never said he wrote it.

IMHO he has jumped off the deep end of the swimming pool before he has learned to walk. My suggestion is to put this program aside for awhile and learn the basic of programming. After a few months' studying and learning you might be ready to tackle this program again.

commented: werd, dawg. thats what i was sayin' yo. :P +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.