2014-01-19 10 views
0

컴퓨터 과학 MOOC CS50을 위해 제출해야하는 과제가 있습니다. 그 안에는 하버드 웹 사이트에서 과제를 제출해야하지만 "경고 : 암시 적 선언"이라고하는 동안 코드를 수락하지 않습니다.경고 : 암시 적 선언

차단하는 방법이 있습니까?

나는 두 가지 기능, islower()isupper()을 가지고 있으며, 이는 전화 끊기의 원인입니다.

내 코드는 잘 작동하는 것처럼 보이며, 컴파일되고 모든 것. BTW 누군가가 내 코드가 얼마나 진절머리 나는지 말해 주길 원한다면 그 점이 인정 될 것입니다. 나는 웹을 통해 수업을 듣는 비판을 많이 듣지는 않는다.

#include <stdio.h> 
#include "cs50.h" 
#include <stdio.h> 
#include <string.h> 

int main(int argc, string argv[]) 
{ 
    int salt, cipherNum; 
    char cipher[40]; 
    char letter; 


    //// Greeting 
    printf("Please enter the text to ceez...\n"); 
    //// grab text 

    string txxt = GetString(); 


    if (argc == 2) // must have command line argument 
    { 

     salt = atoi(argv[1]) % 26; 
     //printf("Salt: %d\n", salt); 
    } 

    else // yell at user if command line arg is not there 
    { 
     printf("Not cool! I need something to caesariphy...\n"); 
     return 1; 
    } 

    //~ 
    // This will iterate over each letter in the text 
    for (int i = 0, n = strlen(txxt); i < n; i++) 
    { 
     // int letter = 'A'; i.e. 65 
     // Must Preserve Case 

     //~ printf("%c---\n", txxt[i]); 

     //if lower start from 'a'or 97 
     if (islower(txxt[i])) 
     { 
      //~ printf("islower\n"); 
      letter = txxt[i]; 
      cipherNum = txxt[i]; 
      //~ printf("%c is the letter\n", letter + salt); 
      //~ printf("%d is the cipherNumz\n", cipherNum); 

      if ((letter + salt) > 122) 
      { 
       //~ printf("letter + salt is > 90: %d \n", letter+salt); 
       cipherNum = (96 + (cipherNum + salt) % 122); 
       //~ printf("%c is the letters", cipherNum); 
      } 
      else 
      { 
       cipherNum = letter + salt; 
      } 



      cipher[i] = cipherNum ; 

     } 
     else if (isupper(txxt[i])) 
     { 

      letter = txxt[i]; 
      cipherNum = txxt[i]; 
      //printf("%c is the letter\n", letter + salt); 
      //printf("%d is the cipherNumz\n", cipherNum); 

      if ((letter + salt) > 90) 
      { 
       //printf("letter + salt is > 90: %d \n", letter+salt); 
       cipherNum = (64 + (cipherNum + salt) % 90); 
       //printf("%c is the letters", cipherNum); 
      } 
      else 
      { 
       cipherNum = letter + salt; 
      } 

      //printf("%c\n", cipherNum); 
      cipher[i] = cipherNum ; 
      //printf("testing12\n");  
     } 
     else 
     { 
      cipher[i] = txxt[i]; 
     } 
     //~ 

    } 
    cipher[strlen(txxt) + 1] = '\0'; 
    printf("%s\n", cipher); 


    return 0; 
} 
+0

여기서'Getstring' 함수는 어디에 있습니까. – haccks

+0

그런 종류의 농담이 나는가? – JonnyTruelove

답변

6

당신이 표준 islowerisalpha를 사용하는 경우, 다음 어딘가에 상단에 당신은 그렇게 할

#include <ctype.h> 

을 볼 수 있습니다.

+0

감사합니다. 나는 프로토 타입을 만들려고했지만, 이제는 "스칼라 타입의 표현이 필요합니다"라는 오류가 있습니다. 그러나 당신의 방법은 더 잘 작동합니다! 감사합니다 – JonnyTruelove

+1

표준 함수를 직접 선언 할 필요가 없습니다. 표준 헤더를 사용하십시오. 그게 그들이 거기있는 이유입니다. –

1

헤더 파일에는 해당 함수에 대해 프로토 타입이 선언되어 있지 않으므로 함수 자체는 함축적으로 함수 프로토 타입으로 처리됩니다. 앞서 언급 한 것처럼 필요한 헤더를 추가하십시오.

관련 문제