int main() { Db* db = db_Load(); Cus* cus; Acc* acc; cus = db_AddCus(db, "Suzhou", "320105199509260000", "Juntong Liu", "18661206723"); acc = db_AddAcc(db, 123456, cus); acc_Deposit(acc, 200); acc_Freeze(acc); acc_AddSORec(acc, 1, 10, 1, acc->accountNumber); system("pause"); printf("%s", cus->address); acc_Deposit(acc, 123); db_Print(db, 3); printf("\navg balance is %f", cus_GetAvg(cus, db)); db_Free(db); system("pause"); }
int main(int argc, char **argv) { struct passwd *pw = getpwuid(getuid()); const char *homedir = pw->pw_dir; char db_fname [STR_MAX]; strcpy(db_fname, homedir); strcat(db_fname, DEFAULT_DB_FNAME); extern char *optarg; char * optarg_insert = 0; char * optarg_remove = 0; bool bl_size = 0; bool bl_clear = 0; bool bl_remove = 0; bool bl_insert = 0; char c; while ((c = getopt (argc, argv, "n:r:sc")) != -1) switch (c) { case 'n': optarg_insert = optarg; bl_insert ++; break; case 'r': optarg_remove = optarg; bl_remove ++; break; case 's': bl_size ++; break; case 'c': bl_clear ++; break; default: return Help()-1; } if (bl_insert && bl_remove) return Help()-1; db_Read_File(db_fname); if (bl_size) { printf("%d", Length(sdb)); return 0; } if (bl_clear) { ClearList(&sdb); db_Write_File(db_fname); return 0; } if (bl_insert) { db_Insert(optarg_insert); db_Write_File(db_fname); return 0; } if (bl_remove) { int i = atoi(optarg_remove); if (ListValidOrder(sdb, i)) DeleteByOrder(&sdb, i); else fprintf(stderr, "Out of range\n"); db_Write_File(db_fname); return 0; } db_Print(sdb); ClearList(&sdb); return 0; }