vicsong93

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

struct account {
    char AccName[100000];
    int Age;
    float AccBalance;
    struct account *Next;
};

typedef struct account BankAcc;

void init(struct Account** headOfList);
void insert(struct account **headOfList, char *name, int age, double balance);
void remove(struct account **headOfList, char *name );
void print(struct account *headOfList );

void main() {
    BankAcc *startPtr = NULL;

    int selection;
    printf("Enter selection and following below: \n");
    printf("1. Insert Account \n2. Delete Account \n3. Print All\n");
    printf("Enter your selection : ");
    scanf("%d",&selection);

    while(selection != 5) {
        switch(selection) {
            case 1:
                char *Username;
                char TmpName[10000];
                int UserAge;
                float UserBalance;

                // Enter Account Name
                printf("Enter Account Name : ");
                scanf("%s",&TmpName);
                Username = TmpName;
                // Enter Age
                printf("Enter Age : ");
                scanf("%d",&UserAge);
                // Enter Account Balance
                printf("Enter Account Balance( RM ) :  ");
                scanf("%f",&UserBalance);

                insert(&startPtr,Username,UserAge,UserBalance);
            break;

            case 2:
                char *del;
                char tmpdelete[100000];

                printf("Enter Account Name : ");
                scanf("%s",&tmpdelete);
                del = tmpdelete;
                remove(&startPtr,del);
            break;

            case 3:
                print(startPtr);
            break;

        }

        printf("------------------------------------------------\n");
        printf("Enter selection and following below: \n");
        printf("1. Insert Account \n2. Delete Account \n3. Print All \n");
        printf("Enter your selection : ");
        scanf("%d",&selection);
    }

}
void init(struct Account** headOfList){
    headOfList = NULL;
}

void insert(struct account **headOfList, char *name, int age, double balance) {
    struct account *newPtr;
    struct account *previousPtr;
    struct account *currentPtr;

    newPtr = (account*) malloc(sizeof(account));

    if(newPtr != NULL) {

        //newPtr->AccName = (char *)malloc(40 * sizeof(char));
        strcpy (newPtr->AccName,name);

        newPtr->Age = age;
        newPtr->AccBalance = balance;
        newPtr->Next = NULL;

        previousPtr = NULL;
        currentPtr = *headOfList;

        while(currentPtr != NULL && balance < currentPtr->AccBalance) {
            previousPtr = currentPtr;
            currentPtr = currentPtr->Next; ...