运行 C 程序 returns -1.#QNAN0 而不是存储在浮点变量中的数字

Running C program returns -1.#QNAN0 instead of number stored in floating-point variable

在继续之前,我想说这是我第一次来这里,我还不知道事情是如何运作的,所以请原谅我的任何错误。

编译后,(下面的源代码)除了浮点显示的内容等于 -1 外,一切正常。#QNAN0。有什么帮助吗?提前致谢。代码的某些部分并不完整,例如 switch-case 结构。请暂时这样(除非影响结果)。

C程序的源代码:

#include <stdio.h>
#include <stdlib.h>
float moneyup(float m);


 int main()
{
char name[20];
char x;
int y;
float disp;
int hunger;

printf("\t\t**********************************************\n");
printf("\t\t*                                            *\n");
printf("\t\t*             How To Get Rich Quick!         *\n");
printf("\t\t*                                            *\n");
printf("\t\t**********************************************\n");
printf("\nThis is an experimental command line interface game made by NayNay AKA Nathan\n");
printf("\nPlease pardon the poor user interface.");

for(;;)
{
    printf("\nPlease enter your name(one only)");
    scanf("%s", &name);
    printf("\nThe name you entered is %s. Is this correct? (type y/n for yes or no)\n");
    fflush(stdin);
    x=getchar();

    if(x=='y')                                                  /*This part with the for loop is used to get the name of the*/
    {                                                           /*user and confirm the correctness of that name. If the name is*/
        printf("Okay! Moving on...");                           /*wrong, the user has the option to change it. Bulletproofing used*/
        break;                                                  /*here*/
    }
    else if(x=='n')
    {
        printf("Alright let's try again.");
        continue;
    }
    else
    {
        printf("Let's try this again.");
        continue;
    }
}
printf("\nOkay %s, Let's get this story started",name);
printf("\n\nOne sad dreary morning, %s got up from sleep and went to the kitchen to get breakfast.");
printf("\nUnfortunately for him his pantry only contained a bunch of cockroaches going at it and laying their eggs everywhere");
printf("\nHe then checked his pockets and pulled out his last 5-dollar bill. That was all he had left,");
printf("\nHe bought a sandwich for  and decides to start a business with  as capital");
printf("\n\nChoose how to start");
printf("\n1. Begging.");
printf("\n2. Mow lawns.");
printf("\n3. Apply for post of newspaper boy.");
fflush(stdin);
y=getchar();

switch(y)
{
    case '1':
        printf("You begged for 6 hours and got .25\n");
        disp=moneyup(5.25);
        printf("You now have $%f\n",disp);
}
return 0;
}

float moneyup(float m)
{
float money;

money=(float)money+m;
return(money);
}

变量money在表达式

中使用时在函数moneyup中未初始化
money=(float)money+m;