행복한 프로그래밍

왜 실행이 안 될까??

영웅*^%&$ 2018. 2. 2. 09:13
728x90

#include <stdio.h>
#define MAXLINE 1000 /*maximum input line length */

int getline(char line[], int max);
int strindex(char source[], char searchfor[]);
char pattern[] = "ould"; /*pattern to search for */

/*find all line matching pattern */
main()
{
    char line[MAXLINE];
    int found = 0;

    while (getline(line, MAXLINE)>0)
    if (strindex(line, pattern) >= 0){
        printf("%s", line);
        found++;
        }
        return found;
    }

    /*getline: get line into s, return length */
    int getline(char s[], int lim)
    {
        int c, i;

        i = 0;
        while (--lim > 0 && (c=getchar() ) !=EOF && C != '\n')
            s[i++] = c;
        if (c== '\n')
            s[i++] = c;
            s[i] = '\0';
        return i;
        }

        /*strindex: return index of t in s, -1 if none*/
        int strindex(char s[], char t[])
        {
            int i, j, k;

            for(i = 0; s[i] !='\0' && s[j]==t[k]; j++, k++)
            ;
            if (k > 0 && t[k] == '\0')
            return i;
            }
            return -1;
        }

728x90

'행복한 프로그래밍' 카테고리의 다른 글

고치는 방법  (0) 2018.02.03
java 피보나치   (0) 2018.02.02
I don't know but I am happy   (0) 2018.02.02
new start  (0) 2018.02.02
피보나치 수열   (0) 2018.02.02