forked from nishushah93/LicensePlateReaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database2.c
61 lines (40 loc) · 1.23 KB
/
database2.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "database.h"
Owner newOwner(char *state, char *number)
{
char firstname[10];
char lastname[10];
printf("Please enter your First name: ");
scanf("%s",firstname);
printf("Please enter your Last name: ");
scanf("%s",lastname);
struct Owner nOwner;
strcpy(nOwner.firstName ,firstname);
strcpy(nOwner.lastName ,lastname);
strcpy(nOwner.licencePlateInfo.state, state);
strcpy(nOwner.licencePlateInfo.platenumber ,number);
return nOwner;
}
char * getCurrentDirectory()
{
char cwd[1024];
if (getcwd(cwd, sizeof(cwd)) != NULL)
fprintf(stdout, "Current working dir: %s\n", cwd);
else
perror("getcwd() error");
strcat(cwd, "/test.xml");
return cwd;
}
void WriteToXML(Owner owner)
{
FILE *fp ;
char * cwd = getCurrentDirectory();
fp = fopen(cwd, "a");
fprintf(fp,"<owner firstName='%s' lastName='%s'> \n <state>%s</state> \n <code>%s</code> \n</owner> \n",owner.firstName,owner.lastName,owner.licencePlateInfo.state,owner.licencePlateInfo.platenumber);
fclose(fp);
}
// Owner owner;
// owner = newOwner();
// WriteToXML(owner);