'Why is my atm project giving return value of 3221225477 when it should be working?

My code:

#include <conio.h>
int atm();
int process();
int enquiry();
int bye();
int withdrawl();
int aiw;
int aib = 20000;
int main(){
    atm();
}
int atm(){
    int v;
    int bankpin = 1234;
    printf("Welcome to atm!");
    printf("\nPlease enter your Bank pin: ");
    scanf("%d",&v);
    
    if(v == bankpin){
        process();
    }
    else{
        printf("\nWrong bank pin! please try again");
        atm();
    }
}
int process(){
    int choice;
    printf("\nWhat would you like to do?: ");
    printf("\n1 for bank enquiry");
    printf("\n2 for withdrawl");
    printf("\n3 to exit");
    scanf("%d",choice);
    
    if(choice == 1 || choice == 2 || choice == 3){
     if(choice == 1){
        enquiry();
     }
     if(choice == 2){
        withdrawl();
     }
     if(choice == 3){
        bye();
     }
    }
    else{
        printf("Error.");
        atm();
    }
    
}
int enquiry(){
    printf("\nYour bank balance is",aib);
    printf("\nAmount in wallet is",aiw);
    atm();
}
int bye(){
    printf("\nThank you for using atm!");
    getch();
}
int withdrawl(){
    float atw;
    printf("\nHow much money would you like to withdraw?");
    scanf("%f",atw);
    if(atw > aib){
        printf("Insufficient funds! Plase try again");
        atm();
    }
    if(atw <= aib){
        aib = aib-atw;
        aiw = aiw+atw;
        printf("Succesfully withdrawn! please check your bank balance");
        atm();
    }
    
}

My output:

Welcome to atm!
Please enter your Bank pin: 1234

What would you like to do?:
1 for bank enquiry
2 for withdrawl
3 to exit1

--------------------------------
Process exited after 6.162 seconds with return value 3221225477
Press any key to continue . . .

Why is this happening? It should continue with the other functions, it happens a lot with scanf, it gets annoying fast!



Solution 1:[1]

Looks as if you are directly returning a view after a post request, when you should be redirecting. Returning a redirect response to the page you need after succesful registration should fix your problem. The easiest way to do it in spring in your case should be returning - "redirect:/your-redirect-url".

This SO question should be useful as well.

Also this - how to redirect.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chaosfire