2016-10-18 9 views
-6

何らかの理由で、私のprintfとscanfが明らかに宣言されていません。私はそれが私が非常によく理解していない私の機能と関係があると思う。単純なカウントプログラムの問題

#include<stdlib.h> 
#include<stdlib.h> 
#include<ctype.h> 

void testCount(); 

int eleven = 11; 
int input = 0; 
int output = 0; 
int count = 0; 

int main(){ 
    printf("What number would you like to count to?"); 
    scanf("%d", &count); 
    testCount(); 
    system("pause"); 
    return 0; 
} 

void testCount (int x){ 
    int y; 
    for(y=1;y<count;y++){ 
     if (x < 10){ 
      x + 1; 
     } 
    }  
    output = input/eleven; 
} 
+1

を; '、また、あなたが' count'を渡すことを忘れ'testCount();' –

+2

これまでにない最も奇妙なプログラム! – AhmadWabbi

答えて

2

あなたはprintf()scanf()の問題を修正する#include <stdio.h>する必要があります。 #include <stdlib.h>が2回あります。

また、あなたが変更する必要があります。

void testCount(); 

へ:

void testCount (int x); 

@慧音欲望によって示唆されているように。そして、新たに発行されたtestCount()関数に価値を渡すことを忘れないでください!

+0

* facepalming * ... – Treycos

+0

さて、申し訳ありませんが、かなり愚かな間違いでした。助けてくれてありがとう:) – SubZeroFish

+0

時には、最も単純なものを見るために目玉の別のセットが必要です:) –

0

プログラムのエラーがたくさんあります。

  1. <stdlib.h>を2回宣言しました。
  2. 出力するために何も印刷しません。
  3. testcount()はOutputを出力するか、main()に返します。
  4. testcount()はargumnetとしてカウントされます。

    次のように変更します。testCount` `のプロトタイプと機能署名は、`無効testCount(int型)への変更を異なっ

    #include <stdlib.h> 
    #include <stdio.h>  //declaration of stdio lib 
    #include <ctype.h> 
    
    void testCount (int); // declaration of datatype of parameter 
    
    int eleven = 11; 
    int input = 0; 
    int output = 0; 
    int count = 0; 
    
    int main() 
        { 
    printf("What number would you like to count to?"); 
    scanf("%d", &count); 
    testCount(count);   // pass value of count so function testcount() can copy that value to variable x 
    system("pause");  // no need of this line 
    return 0; 
    } 
    
        void testCount (int x) 
        { 
        int y; 
        for(y=1;y<count;y++) 
        { 
    
    
    if (x < 10) 
        { 
        x + 1; 
        } 
        }  
        output = input/eleven; 
    
        printf("Output is :%d",output); 
        } 
    
+0

ありがとう、私は今それを固定したと思う。 – SubZeroFish