C 从该函数传递值
用途:此程序允许用户在马上下注 在一场用上述赌注赚钱的比赛中。我正在尝试运行configureBalance函数,然后将钱添加到余额中。我收到一个异常读取访问冲突 */ 这直接增加了平衡C 从该函数传递值,c,visual-studio,math,parameter-passing,pass-by-reference,C,Visual Studio,Math,Parameter Passing,Pass By Reference,用途:此程序允许用户在马上下注 在一场用上述赌注赚钱的比赛中。我正在尝试运行configureBalance函数,然后将钱添加到余额中。我收到一个异常读取访问冲突 */ 这直接增加了平衡 if (configureMenuChoice == 'A') { CLS; printf("How much would you like to add to your account balance? \n"); 更改此项: scanf("%i", &deposit)
if (configureMenuChoice == 'A') {
CLS;
printf("How much would you like to add to your account balance? \n");
更改此项:
scanf("%i", &deposit);
*balance = *balance + *deposit;
}
if (configureMenuChoice == 'C') {
CLS;
currentBalance(*balance); // displays current balance, made a functino so it can be used at will
}
}//end conFigureBalance
void currentBalance(int *balance) {
printf("Your current balance is: %i\n", &balance);
}//end checkBalance
为此:
scanf("%i", &deposit);
因为在该上下文中,deposit
属于int*
类型(函数体configureBalance
)
这与下面的逻辑相同:
scanf(“%c”,userChoice)代码>,所以我想知道你怎么会错过它。@Deonte-threat应该有scanf(“%I”,存款);而不是scanf(“%i”&存款);在函数中。我更改了它,但当我将存款添加到余额中时,它会在值中显示。
scanf("%i", &deposit);
*balance = *balance + *deposit;
}
if (configureMenuChoice == 'C') {
CLS;
currentBalance(*balance); // displays current balance, made a functino so it can be used at will
}
}//end conFigureBalance
void currentBalance(int *balance) {
printf("Your current balance is: %i\n", &balance);
}//end checkBalance
scanf("%i", &deposit);
scanf("%i", deposit);