A very rudimentary more, press enter to view next screenful of text, like with print command in ed text editor.
Rudimentary more
/*
** rmore.c -- rudimentary more, public domain by tkorrovi@mail.com
** Press enter for next page, this is all we have in ansi c
*/
#include <stdio.h>
#define LINES 25
int main (int argc, char *argv [])
{
FILE *file;
char line = 0, ch;
if (argc == 1) return 1;
if ((file = fopen (argv [1], "rb")) == NULL) return 1;
while ((ch = getc (file)) != EOF)
{
if (putchar (ch) == '\n')
{
if (++line == LINES - 1)
{
line = 0;
printf ("-- More -- ");
if (getchar () == 'q') return 0;
}
}
}
return 0;
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.