숫자와 함께 숫자 이외의 알파벳들도 같이 입력받아서 int형 숫자로 출력하는 프로그램을 만들려하는데 코드하나가 오류가 나네요 이유를 모르겠어요

조회수 382회
#include<stdio.h>

int myatoi(char[]);

void main()
{
    char string[81];
    int re;
    printf("Enter the string: \n");
    gets_s(string,81);
    re=myatoi(string);
    printf("result is %d", re);
}

int myatoi(char str[]) {
    int i = 0, j = 0;

    if (str[0] == '+' || str[0] == '-') {
        while (str[i] != '\0') {
            str[i] = str[i + 1];
            i++;
        }
    }






//이 부분 이후에서 오류가 납니다.



    int p = 0;
    while (str[j] != '\0') {
        if (str[j] >= '0' && str[j] <= '9') {
            j++;
        }
        else {
            while (str[p] == '\0') {
                str[p] = str[p + 1];
                p++;
            }
        }

    }
        int k = 0, t = 0, m = 1, result = 0;
        while (str[i] != '\0') {
            k++;
        }
        for (t; t < k; t++) {
            m = m * 10;
        }
        i = 0;
        while (str[i] != '\0') {
            result = result + str[i] * m;
            m = m / 10;
            i++;
        }
        return result;
    }
  • 오류도 같이 써줘요. nowp 2020.6.20 20:39

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)