-
Notifications
You must be signed in to change notification settings - Fork 0
/
COMP-206-Ass-6.txt
100 lines (75 loc) · 2.03 KB
/
COMP-206-Ass-6.txt
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Student Name : Yordan Radev
// Student ID : 260 744 314
gured it out####################################################################################################
linked.c
####################################################################################################
struct ACCOUNT *head = NULL
struct ACCOUNT
{
int accountNumber;
float balance;
struct ACCOUNT *next;
}
void findUpdate(int account, int amount);
{
currACCOUNT = head;
while(currACCOUNT.next != NULL)
if(currACCOUNT == account)
currACCOUNT.balance + ammount;
return 0
AACCOUNT.account= account;
ACCOUNT.ammount = ammount;
ACCOUNT.next = NULL;
currACCOUNT.next = ACCOUNT
}
void prettyPrint();
{
currentACCOUNT = head;
while(currentACCOUNT.next != NULL)
{
printf("ACCOUNT ID: %5i \t BALANCE: $ %9.2f", *acct, *amnt)
}
}
####################################################################################################
main.c
####################################################################################################
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "linked.c"
#include "ssv.c"
int main(int argc, char *argv[]) {
FILE *p;
p = fopen("file.ssv",
open file.ssv
while(fgets(record,100,,p) != NULL)
{
accammt[] = parse(record);
findupdate(accammt[0],accammt[1]);
}
while(fgets(record,100,,p) != NULL)
{
prettyprint();
}
Loop through all the records and call parse (whose pointers *acct and *ammt you pass to findUpdate)
Then loop thorugh and call prettyprint
fclose(p);
return 1
}
####################################################################################################
ssv.c
####################################################################################################
void parse(char record[], int *acct, float *amnt);
{
# string separator = " "
# string accounts;
# string ammounts;
# Nope use sscanf
char delim[] = " ";
char *pt:wq
r = strtok(record, delim);
sscanf(record[], "%i %f", accounts,ammounts )
*acct = atoi(account);
*amnt = atof(ammounts);
}