All pastes #2080008 Raw Edit

Unnamed

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

#define MAXLINE 1000

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

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

    max = get_int();
    while ((len = get_line(line, MAXLINE)) > 0) {
        if (len > max)
            printf("%s", line);
        max = get_int();
    }
}

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;
}