All pastes #2080009 Raw Edit

Mine

public text v1 · immutable
#2080009 ·published 2011-09-06 01:04 UTC
rendered paste body
#include <stdio.h>

#define MAXLINE 1000

int get_line(char line[], int maxline);

main()
{
    int len, max;
    char line[MAXLINE];

    printf("Print line if over: ");
    scanf("%d", &max);
    while ((len = get_line(line, MAXLINE)) > 0) {
        if (len > max)
            printf("%s", line);
        printf("Print line if over: ");
        scanf("%d", &max);
    }
}

int
get_line(char s[], int lim)
{
    int c, i;

    printf("Enter line: ");
    for (i = 0; i < lim-1 && (c = getchar()) != EOF && c != '\n'; ++i)
        s[i] = c;
    if (c == '\n') {
        s[i] = c;
        ++i;
    }
    s[i] = '\0';
    return i;
}

int
get_int()
{
    int i;
    printf("Print line if over: ");
    scanf("%d", &i);
    return i;
}