2016-10-07 9 views
-2

このサイトを初めてご利用いただき、まことにありがとうございます。私は大学でのプログラミングに関する講義を受けており、エラーを解消するコードが与えられました。私はこの問題を抱えており、事前に感謝しています。私が持っている主な問題は、 "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; 
} 
+3

loop_counterエラーは一般的ではありません。その行の前と後の文を注意深く見ると、何かが見つからないことがわかります。 –

+2

また、関数UpdateWeatherStationの場所とFunctionFooの場所を、呼び出された場所と比較して注意深く見てください。 –

+1

FunctionFooのプロトタイプはどこですか? – Raindrop7

答えて

-1

あなたのコードは間違いだらけです:

の1-機能FunctionFooのプロトタイプがありますか?

2-ここで、 ';'ステートメントの終わりです。メインの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;  
} 
+0

返信いただきありがとうございます!先ほどお話したように、私はプログラミングには全く新しいです。あなたが読んだことがとても上手だから私は推測します。私はあなたがこの言語のC++に慣れていないことがわかります。将来的には建設的な批判ほど単純なものが大いに評価されるだろう。 – tytytyui

+0

ok!読書をする。 – Raindrop7

関連する問題