This is a section of my function where if the scores were shifted (1) then it prints "Shift amount?" after and collects user input to be used in the compute_total(earned,shifted, shift)
function:
printf("Were scores shifted (1=yes, 2=no)? ");
double shifted;
scanf("%lf", &shifted);
if(shifted == 1){
printf("Shift amount? ");
double(shift);
scanf("%lf", &shift);
}else{}
double total = compute_total(earned, shifted, shift);
However, obviously I cannot access the variable inside of the if-statement, when I bring the variable and scanf for shift outside of the if scope then the program will run but as I enter a digit for shift amount the terminal does not go any further through my program, it gets "stuck".
How should I solve this issue so I can access the variable but still function correctly?
question from:
https://stackoverflow.com/questions/65949776/how-to-access-a-variable-inside-of-an-if-statement 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…