Start New Discussion within our Software Development Community

A very rudimentary more, press enter to view next screenful of text, like with print command in ed text editor.

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