Hi, I am trying to get an employee database to work correctly, I thought that all the coding was correct but everytime I run my code i get a return of -1, help would be appreciated: -
#include <stdio.h>
-
-
typedef struct Employee
-
{
-
char fname[20];
-
char lname[20];
-
char sub_taken[20];
-
char last_edu[20];
-
char join_date[20];
-
int id;
-
int age;
-
float bsal;
-
}Employee;
-
-
int main(void)
-
{
-
-
int id;
-
FILE *fp,*ft;
-
char another,choice;
-
Employee emp;
-
char fname[20];
-
char lname[20];
-
long int recsize;
-
-
fp=fopen("EMP.DAT","rb+");
-
if(fp==NULL)
-
{
-
fp=fopen( "EMP.DAT","wb+");
-
if(fp==NULL)
-
{
-
printf("
-
Can't Open File");
-
exit();
-
}
-
}
-
recsize=sizeof(emp);
-
while(1)
-
{
-
printf("
-
1.Add Records
-
2.Delete Records
-
3.Modify Records
-
-
4.List
-
Records
-
5.Exit");
-
printf("
-
-
Enter your choice");
-
fflush(stdin);
-
scanf("%c",&choice);
-
switch(choice)
-
{
-
case'1':
-
fseek(fp,0,SEEK_END);
-
another='Y';
-
while(another=='Y'|| another=='y')
-
{
-
printf("Enter the first name,last name,age and basic salary : ");
-
scanf("%s %d %f",emp.fname,&emp.age,&emp.bsal);
-
printf("
-
Enter joining date,id,last education,subject taken");
-
scanf("%s %d %s %s",emp.join_date,&emp.id,emp.last_edu,
-
emp.sub_taken);
-
fwrite(&emp,recsize,1,fp);
-
printf("
-
Add another Record (Y/N): ");
-
fflush(stdin);
-
another=getchar();
-
}
-
-
break;
-
case '2':
-
another='Y';
-
while(another=='Y'|| another=='y')
-
{
-
printf("
-
Enter the id of the employee to be deleted : ");
-
scanf("%d",&id);
-
ft=fopen("TEMP.DAT","wb");
-
rewind(fp);
-
while(fread(&emp,recsize,1,fp)==1)
-
{
-
if(strcmp(emp.id,id)!=0)
-
fwrite(&emp,recsize,1,ft);
-
}
-
fclose(fp);
-
fclose(ft);
-
remove("EMP.DAT");
-
rename("TEMP.DAT","EMP.DAT");
-
fp=fopen("EMP.DAT","rb+");
-
printf("Delete another Record(Y/N): ");
-
fflush(stdin);
-
another=getchar();
-
}
-
-
break;
-
case '3':
-
another='Y';
-
while(another=='Y'|| another=='y')
-
{
-
printf("
-
Enter name of employee to modify : ");
-
scanf("%s",emp.fname);
-
rewind(fp);
-
while(fread(&emp,recsize,1,fp)==1)
-
{
-
if(strcmp(emp.id,id)==0)
-
{
-
printf("
-
Enter new fname,new lname,age,basic
-
salary,joining_date,subject taken and last education : ");
-
-
scanf("%s%s%d%f%s%s%s",emp.fname,emp.lname,&emp.age,&emp.bsal,emp.join_dat
-
e,emp.sub_taken,emp.last_edu);
-
fseek(fp,-recsize,SEEK_CUR);
-
fwrite(&emp,recsize,1,fp);
-
break;
-
}
-
}
-
printf("
-
Want to Modify another record(Y/N): ");
-
fflush(stdin);
-
another=getchar();
-
}
-
-
break;
-
-
case '4':
-
-
rewind(fp);
-
while(fread(&emp,recsize,1,fp)==1)
-
printf("
-
%s %s %d
-
%g",emp.fname,emp.lname,emp.age,emp.bsal,emp.join_date,emp.last_edu,emp.su
-
b_taken);
-
break;
-
-
case '5':
-
fclose(fp);
-
exit();
-
-
}
-
}
-
}
1 2995
Your code won't even compile.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jonnie |
last post by:
I am in the process of building an employee database for use by the
management team here. They current have Access 97 (I am working on
getting them to upgrade to at least 2000). For the most part I have it
under control. There are several points that have popped up as wanted
features and I need to verify somethings.
1. We now want to add the ability to add comments/notes with time and
date stamps to an employees record. These comments...
|
by: RR |
last post by:
I am wondering what tables and relationships I would have to have to keep
track of one or several employees commissions per transaction.
One tracsaction can have one or several employees work on it, and the
commissions for each employee depends on how many employees worked on it.
Thanks
|
by: Chris Strug |
last post by:
Hi,
As something of a pet project, I'm looking to develop a tool to track
employee holiday (or vacation for those of us in the US) for my company -
good for the company (if I get something usuable working) and good practice
for me.
Before I even open Access I want to get the relationships sorted.
First looks indicate two basic entities:
|
by: RSH |
last post by:
I am really trying to grasp the concept of OOP as it applies to C#.
I am looking at trying to set up a simple Employee Class but I am having
trouble conceptualizing what this class should look like. I was hoping
someone might be able to simply outline what I envision my class to look
like:
Basically I am envisioning a Class called Employee:
I imagine it would have many properties(?) such as:
|
by: Akinyemi |
last post by:
I am creating a database in MSAccess 2000 for my Payroll Program I am writing. I want to save an image representing an employee in the record of each employee. I then want to post the name of each employee and the image I have save in each record of each employee on Visual Basic Form.
How do I do this?
I need your help.
Akinyemi
| |
by: Maddy |
last post by:
I manage a small organisation of around 100 employees, with different
specialisations. It becomes difficult to check how many persons of
each specialisation are available at any time, based on their vacation
period. So I have made a ms-acces database as follows -
A table EMPL with details of employees.
A table SPEC with the various specialisations.
The EMPL table has a specialisation field linked to the SPEC table.
Finally a VACATION...
|
by: andrewCMF |
last post by:
Hello
I hope this is posted in the correct place, if not the can some point
me in the direction of a suitable Google group.
ok, here's my problem......
When an employee logs into their PC, we want to record the "log in"
time and then the "log off" time at the end of the day and record the
two times in a SQL Database. This is for the purpose of working out
|
by: petepell |
last post by:
Hello all,
I am developing an application in VB 2008 that works with a SQL2005 DB to store and manipulate employee data. In one section of the app I want to be able to show a treeview of the hierarchy as a whole showing a nested hierarchy of who reports to who such that when it is first loaded, all you will see is the top guy in the company with a plus next to his name. Opening that will reveal his first level reports and opening those will...
|
by: JennDavila |
last post by:
Hello,
I am running into an issue with adding a form that displays a calendar to where the manager can click a day and it will attach itself to a tracking table. I am new to this and have been given this project as a learning exp. I need all the help I can get on where to begin.
I have created tables- one of with employee information, another with reason codes for day off requests (such as jury duty, vacation, sick time, etc). And a table...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |