add a new record in a file

we have already existance 7 employee in a file named employee.txt.the

Page 1 of 1

3 Replies - 6357 Views - Last Post: 25 May 2010 - 11:08 AM Rate Topic: -----

#1 rosaline  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-October 09

add a new record in a file

Posted 09 October 2009 - 06:56 AM

we have already existance 7 employee in a file named employee.txt.the problem is , we cannot add a record of a new employee.
it appears a blank screen when we run the program.

#include <stdio.h>

int main()

{

char name[10][244];
char icnumber[10][244];
char phonenumber[10][244];
int salary[10];
int i, count=0;

FILE * employee;
employee=fopen("employee.txt","a");
fprintf(employee,"\n%s %s %s %d",name,icnumber,phonenumber,salary );




for (i=0; i<count; i++)
{
printf("\n %d. %s",i, name[i]);
}


printf("\n To add record press enter :");

printf("\n enter your name : ");
scanf("%s" , name);
printf("\n enter your icnumber : ");
scanf("%s" , icnumber);
printf("\n enter your phonenumber : ");
scanf("%s" , phonenumber);
printf("\n enter your salary : ");
scanf("%d" , &salary);


return 0;

}

This post has been edited by rosaline: 09 October 2009 - 08:39 AM


Is This A Good Question/Topic? 0
  • +

Replies To: add a new record in a file

#2 ccubed  Icon User is offline

  • It's That Guy
  • member icon

Reputation: 160
  • View blog
  • Posts: 1,403
  • Joined: 13-June 08

Re: add a new record in a file

Posted 09 October 2009 - 07:49 AM

Well, you haven't coded it to. I see you getting input, but you don't write it before the program ends. Or are you saying that the initial append printf doesn't work?

Also, put code tags around your code please. :P
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Teddy*


Reputation:

Re: add a new record in a file

Posted 25 May 2010 - 11:07 AM

great :) it worked for me
Was This Post Helpful? 0

#4 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1072
  • View blog
  • Posts: 4,532
  • Joined: 09-June 09

Re: add a new record in a file

Posted 25 May 2010 - 11:08 AM

please post with code tags next time :)
:code:

This post has been edited by ImaSexy: 25 May 2010 - 11:09 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1