K and R C, Solution to Exercise 5-14:
K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition) . You can learn and solve K&R C Programs Exercise.
Write a C program to handle a -r flag which indicates sorting in reverse (decreasing) order. But sure that -r works with -n.Read more about C Programming Language .
K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition)
Write a C program to handle a -r flag which indicates sorting in reverse (decreasing) order. But sure that -r works with -n.Read more about C Programming Language .
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define MAXLINES 5000
char *lineptr[MAXLINES];
#define MAXLEN 1000
int reverse = FALSE;
int getline(char s[], int lim)
{
int c, i;
for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != 'n'; i++)
s[i] = c;
if (c == 'n') {
s[i++] = c;
}
s[i] = '