Adding New Data to A File

Hi , I'm trying to figure out how to add new data to a file using a structure and a function. I have some of the code required but I am struggling with how to add the actual new members of the new data(within the structure) to the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//this is just a sample to my full code 


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

struct cust_rec
{
    int cust_id;
    char firstname[11];
    char surname[21];
    int age;
    char gender;
    char address[41];
};

void new_cust(void);

main()
{

    new_cust(void);

    system("PAUSE");
}

void new_cust(void)
{
/* 
this is the point where I don't understand where I am to assignment the new
data to the structure template
-- i know a file needs to be opened for new data to be entered but its the actual adding of the data which has me bothered.(basically all the code within the function)
*/

  printf("Please Enter New ID");
   printf("Please Enter New Firstname");
 printf("Please Enter New Surname ");
 printf("Please Enter New Age");
 printf("Please Enter New Gendre");
 printf("Please Enter New Address");
}
Are you just adding to the end of the file? If so, just use the ios::app flag when opening the file.
I dont know what that means, would you mind sending me some commented code within my code to show where i need to put it
Topic archived. No new replies allowed.