PCOMPLETE문제 컴파일 오류요..

  • Aileen
    Aileen

    <<코딩내용 C로 작성>>

    #include <stdio.h>
    #include <string.h>
    
    int testcase,len,p,q,a,b,time;
    char str[1000]="";
    
    int main(){
        scanf_s("%d", &testcase);
    
        while(testcase){
            len=0;
            time=0;
            p,q,a,b=0;
            int i=0;
    
            scanf_s("%d", &len);
            scanf_s("%s", str, len+1);
            scanf_s("%d %d", &p, &q);
    
            if(p<q){
                a=p, b=q;
            }
            else{
                a=q, b=p;
            }
    
            i=0;
    
            while(i <= len-i-1) {
    
                if(str[i]=='?' && str[len-i-1]=='?'){
                    if(len-i-1 != i)
                        time += 2*a;
                    else
                        time+=a;
                }
    
                else if(str[i]=='?'&& str[len-i-1]=='a')
                    time+=a;
                else if(str[i]=='?'&& str[len-i-1]=='b')
                    time+=b;
                else if(str[i]=='a' && str[len-i-1]=='?')
                    time += a;
                else if(str[i]=='b'&& str[len-i-1]=='?')
                    time+=b;
    
                i++;
            }
    
            printf("%d\n", time);
            testcase--;
        }
    
        return 0;
    }
    
    ----------------------------------------------------------------                         
    <<컴파일오류>>
    
    submission.cpp:8:24: warning: ignoring return value of int scanf(const char*, ...), declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d", &testcase);
                            ^
    submission.cpp:16:20: warning: ignoring return value of int scanf(const char*, ...), declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &len);
                        ^
    submission.cpp:17:19: warning: ignoring return value of int scanf(const char*, ...), declared with attribute warn_unused_result [-Wunused-result]
       scanf("%s", str);
    
    -------------------------------------------------------------
       이렇게 오류가 났습니다
       근데 무슨의미인지  모르겠네요..ㅠㅠ
       비쥬얼스튜디오 2013에서는  돌아가요.. 오류없이 !!
    

    9년 전
3개의 댓글이 있습니다.
  • leekeezz
    leekeezz

    scanf_s는 visual studio에서 쓰는 거라서 표준함수인 scanf로 쓰셔야해요


    9년 전 link
  • Aileen
    Aileen

    넴 알겠습니다. 근데 아래에 const char*는 무슨의미인지ㅠㅠ;


    9년 전 link
  • Being
    Being

    올려주신 부분들은 경고라 컴파일에는 문제가 없습니다. 제출하신 기록을 살펴 보니 컴파일 에러가 있습니다만, 왜 경고만 가져다가 올리셨나요?


    9년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.