Showing posts with label Coding Of Data Entry Or Add Records. Show all posts
Showing posts with label Coding Of Data Entry Or Add Records. Show all posts

Saturday, 27 October 2012

Program Of Append Records Using C

Coding Of Append Records Using c


#include<stdio.h>
 
#include<conio.h>
 
   {
    
   char   name[10];
   
    int    number;
  
     float  price;
   
    int    quantity;
 
   };
 
 void main()
 
   {
  
    char  filename[10];
    
   int   response; 

       FILE  *fp;
 
       long  n;
   
      printf("Type filename:");
 
      scanf("%s", filename);
    
   fp = fopen(filename, "a+");
 
       do
 
       {
 
      append(&item, fp);
    
  printf("\nItem %s appended.\n",item.name);
     
 printf("\nDo you want to add another item\        (1 for YES /0 for NO)?");
    
  scanf("%d", &response);
 
       } 
 while (response == 1);
    
       n=ftell(fp);
 
       fclose(fp);
    
   fp = fopen(filename, "r");
 
  while(ftell(fp) < n)
 
       {
    
  fscanf(fp,"%s %d %f %d",
      item.name, &item.number, &item.price, &item.quantity); 
     
 fprintf(stdout,"%-8s %7d %8.2f %8d\n",
    
  item.name, item.number, item.price, item.quantity);
 
       }
   
    fclose(fp);
 
  getch();
 
   }
 
 

Friday, 26 October 2012

Program Of Data Entry Or Add Records Using C

#include<stdio.h> 
#include<conio.h>
 
#include<string.h>
 
{
 

char name[40];
 

int age;
 

float bs;
 

};
 

main()
 

{
 

clrscr();
 

FILE *fp;
 
struct emp e;
 
char s[80];
 
char another='y';
 
if(fp==NULL)
 
{
 
printf("Can't Open File");
 
exit(1);
 
}
 
printf("\n File  TEXT Is=");
 
printf("\n");
 
printf("\n Enter Name,AGE,Basic salary");
 
scanf("%s",e.name);
 
scanf("%d",&e.age);
 
scanf("%f",&e.bs);
 
printf("Add Another Record(y/n)");
 
another=getche();
 
}
 
fclose(fp);
 
getch();
 
}