I need to write a C program to fetch data from one file and write it to another file, without using user defined functions. My requirements are to:
- Search customer details by Name.
- Store the transaction data (paid amount) in another text file.
I did the code to search by name. But its not working,
#include <stdio.h>
#include <stdlib.h>
int main () {
   char name[10], nic[10], mobile[10];
   char fname[10], fnic[10], fmobile[10];
   char choice;
   int amount;
   FILE *cfptr;
   printf("Enter search type  - \n 1. NAME \n 2. NIC \n 3.MOBILE \n ----> ");
   scanf("%c", &choice);
        printf("Enter search text : ");
        scanf("%s", &name);
        cfptr = fopen ("customer.dat", "r");
        while (!feof(cfptr)){
            fscanf(cfptr, "%s %s %s", fname, fnic, fmobile);
            printf("Read Name |%s|\n", fname );
            printf("Read NIC |%s|\n", fnic );
            printf("Read Mobile |%s|\n", fmobile );
   }
   fclose(cfptr);
   scanf("%d", &amount);
   return(0);
}
customer.dat File
Shan    100012  200202
Marsh   121213  667675
Kim     126573  663412
This code is not complete asI cant filter the single name assigning
if(name == fname)
as am getting
assignment to expression with array type error
Can any one complete me the code to search and save to another file so I can do the amount calculation part?
 
     
     
    