2013-04-11 2 views
1

저는 13 세가되어 C 프로그래밍을 배우므로 믿을 수 없을 정도로 기본적인 C 프로그래밍 이해가 있습니다. '변수 값 표시'하는 방법, 아주 기본적인 코드를 사용하고 있지만 GNU (MinGW)를 사용하여 컴파일하려고 할 때 알려줍니다.vars.c : 4 : 1 : 오류 : 예상 선언 지정자 또는 '...'앞에 '('토큰

vars.c : 4 : 1 : 오류 : 예상되는 선언 지정자 또는 '...'전 '('토큰

내가이 문제를 해결할 수있는 방법을 누군가가

코드입니다 말해 수 있습니다하십시오

!
#include <stdio.h> 

int main(
(printf("Integer is %d \n",num); 
(printf("Values are %d and %f \n",num,pi); 
(printf("%%7d displays %7d \n",num); 
(printf("%%07d displays %07d \n",num); 
(printf("Pi is approximately %1.10f \n",pi); 
(printf("Right-aligned %20.3f rounded pi \n",pi); 
(printf("Left-aligned %-20.3f rounded pi \n",pi); 
return 0 ;) 
) 
({ 
int num = 100; 
double pi = 3.1415926536; 
(return 0 ;) 
}) 
+0

는이 코드를 작성 않았거나이 코드가 당신에게 문제로 주어진? – Ganesh

+3

전에 Lisp이나 Scheme을 배웠습니까? 당신은 너무 많은 괄호를 사용하고 있으며, 그 중 많은 수가 유효하지 않습니다. –

+0

다음은 [C 프로그래밍] (http://www.cprogramming.com/tutorial/c-tutorial.html)을 소개하는 자습서입니다. 즐겨! – Bechir

답변

2

잘 모르겠어요,하지만 난 당신이 다음을 입력하도록 있으리라 믿고있어 :을 찾을 수

#include <stdio.h> 

int main(void) 
{ 
     int num = 100; 
     double pi = 3.1415926536; 

     printf("Integer is %d \n",num); 
     printf("Values are %d and %f \n",num,pi); 
     printf("%%7d displays %7d \n",num); 
     printf("%%07d displays %07d \n",num); 
     printf("Pi is approximately %1.10f \n",pi); 
     printf("Right-aligned %20.3f rounded pi \n",pi); 
     printf("Left-aligned %-20.3f rounded pi \n",pi); 

     return 0 ; 
} 

시도를 온라인 C 프로그래밍 자습서를 통해 당신의 방법을 작동합니다. 시행 착오보다 훨씬 만족 스러울 것입니다.

2

사용중인 구문은 세 번째 행에서 시작하는 경우 거의 완전히 잘못되었습니다. 당신은 main의 인자를 선언하는 것을 끝내지 않았고 당신에게는 여분의 괄호가 있었다. Google에 "c hello world"를 제공하고 이러한 예제를 실행하여 C 코드의 모양을 알 수 있도록하십시오.

#include<stdio.h> 

int main() 
{ 
    int num = 100; 
    printf("Hello World\n"); 
    printf("Integer is %d\n",num); 
    return 0; 
} 
+0

고맙습니다. 제 자신보다 앞서 가고 있습니다. 조금 읽을 필요가 있습니다 !!!!! –

0

적어도 세 문제 :

1) 완전히 불필요한 괄호

2) 초기화되지 않은 변수

3) ???을 만들려 여기 도움이되는 예는 주()에 람다 ???

하기 권장 수정 :이 코드를 내놓았다 곳

#include <stdio.h> 

int main() { 
    int num = 100; 
    double pi = 3.1415926536; 

    printf("Integer is %d \n",num); 
    printf("Values are %d and %f \n",num,pi); 
    return 0 ; 
} 
0

코드의 버전을 사용 :

#include <stdio.h> 

int main() { 
    int num = 100; 
    float pi = 3.1415926536; 

    printf("Integer is %d \n",num); 
    printf("Values are %d and %f \n",num,pi); 
    printf("%%7d displays %7d \n",num); 
    printf("%%07d displays %07d \n",num); 
    printf("Pi is approximately %1.10f \n",pi); 
    printf("Right-aligned %20.3f rounded pi \n",pi); 
    printf("Left-aligned %-20.3f rounded pi \n",pi); 

    return 0; 
} 
관련 문제