麻烦错误解决

时间:2016-10-07 21:00:53

标签: c++

我是这个网站的新手,也是编程新手。我正在上大学的课程,我们得到了一个代码来清除错误。我对此有困难,希望得到一些帮助,在此先感谢!我遇到的主要问题是“loop_counter”和“FunctionFoo”未被识别,int loop_counter = 1;期待';'

#include "stdafx.h"

int UpdateWeatherStation(void)
{
    printf("Updating Weather Station\n\n");
    int foo = 5;
    return foo;    
}

void main(void)
{

    printf("\nTech104 Lab02\n\n")

    int loop_counter = 1; 

    int xyz = FunctionFoo();
    int hjk = FunctionFoo();

    while (loop_counter<10)
    {

        printf("Loop #:%d\n", loop_counter);
        int weatherStatus = UpdateWeatherStation();
        printf("weatherStatus=%d\n", weatherStatus);
        printf("\n\n");

        int user_input = getchar();
        if (user_input == '5')
        {
            printf("User entered 5!!!!!\n");
        }

        loop_counter++;
    }
}

int FunctionFoo(void)
{
    printf("Hello\n\n");
    int abc = 5;

    return abc;
}

1 个答案:

答案 0 :(得分:-1)

你的代码充满了错误:

1-哪里是函数FunctionFoo的原型?

2-声明的结尾在哪里;&#39;;&#39;在main?

中的printf()之后
#include <stdio.h>

int FunctionFoo(void);
int UpdateWeatherStation(void);



void main(void)
{

    printf("\nTech104 Lab02\n\n");

    int loop_counter = 1; 

    int xyz = FunctionFoo();
    int hjk = FunctionFoo();

    while (loop_counter<10)
    {

        printf("Loop #:%d\n", loop_counter);
        int weatherStatus = UpdateWeatherStation();
        printf("weatherStatus=%d\n", weatherStatus);
        printf("\n\n");

        int user_input = getchar();
        if (user_input == '5')
        {
            printf("User entered 5!!!!!\n");
        }

        loop_counter++;
    }
}

int FunctionFoo(void)
{
    printf("Hello\n\n");
    int abc = 5;

    return abc;
}

int UpdateWeatherStation(void)
{
    printf("Updating Weather Station\n\n");
    int foo = 5;
    return foo;    
}