Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 从该函数传递值_C_Visual Studio_Math_Parameter Passing_Pass By Reference - Fatal编程技术网

C 从该函数传递值

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)

用途:此程序允许用户在马上下注 在一场用上述赌注赚钱的比赛中。我正在尝试运行configureBalance函数,然后将钱添加到余额中。我收到一个异常读取访问冲突 */

这直接增加了平衡

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);