+ 1
char transaction(char option[1]){
//..
cin>>option;
//next line is no effect,invalid
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
//no returning value, return a value. Else make void return type
}
int main(){
char pin[4];
cin>>pin;
if(pin[4]!=4){ //index 4 is out of range. Max index is 3 only since you declared pin[4] of length 4 only.
cout<< "Invalid";
}
else goto transaction(option[1]); //invalid statement.. No level declared to say goto. But also option[] is not declared here...
//next is invalid statement, If you want add newlines,then add like
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
redefined your code with these changes.. and see
Hope it helps....
edit:
What are you trying by this code actually? What's the task there?
edit:
@Emmanuel Baffoe Appiah-ofori
don't change original question. post updates here in reply
0
#include <iostream>
using namespace std;
char transaction(){
cout<< "1. Withdraw"<<endl
<< "2. Deposit"<<endl
<< "3. Change pin"<<endl
<< "Enter an option: "<<endl;
char option; //single char is enough here.
cin>>option;
return option;
}
int main(){
cout<< "Insert your card"<<endl
<< "Enter your pin: "<<endl;
char pin[4];
cin>>pin;
if(pin[3]>'4'){ //valid indexes are 0 to 3 only
cout<< "Invalid";
}
else
cout<< transaction(); //calling function. print return result
}
/*
edit:
Emmanuel Baffoe Appiah-ofori
just removed errors.
input
1234
1
and see output.
*/