2016-10-07 4 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

코드가 실수로 가득하다 :

기능 FunctionFoo의 프로토 타입입니다

1?

2- 여기서 ';'의 끝은입니다. mainf에서 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

답장을 보내 주셔서 감사합니다. 앞에서 언급했듯이 프로그래밍에 익숙하지 않습니다. 당신이 매우 잘 읽고 있기 때문에 나는이 언어에 익숙하지 않다는 것을 알 수 있다고 생각합니다. 미래에 건설적인 비판처럼 단순한 것이 크게 감사 할 것입니다. – tytytyui

+0

좋습니다! 독서를 잡아라. – Raindrop7