I don't think this is what the op was looking for, but like, here is
what I came up with...
Ditto....
----------------------------cut------------------------------
/*
** capit.c - capitalize first letter of each input line
**
** Input: stdin
** Process: capitalize the first alphabetic character of
** each input line.
**
** If ALLOWLEADINGBLANKS is defined, only capitalize
** if letter is preceeded by zero or more whitespace;
** *DO NOT* capitalize if first letter is preceeded
** by non-whitespace.
** Output: stdout
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define ALLOWLEADINGBLANKS 1
void capit(FILE *input, FILE *output)
{
int datum, linestart;
for (linestart = 1,datum = getc(input);datum != EOF;datum = getc(input))
{
if (linestart)
{
#ifdef ALLOWLEADINGBLANKS
for (;isblank(datum); datum = getc(input)) putc(datum,output);
#endif
if (islower(datum)) datum = toupper(datum);
}
putc(datum,output);
linestart = (datum == '\n' ? 1 : 0);
}
}
int main(void)
{
capit(stdin,stdout);
return EXIT_SUCCESS;
}
----------------------------cut------------------------------
/var/nfs/merlin/lpitcher/code/clc $ cc -o capit capit.c
/var/nfs/merlin/lpitcher/code/clc $ cat capit.txt
first line of the file, starts with lower case letter
line with lower case preceeded by whitespace
& another line
%line preceeded by something
two spaces
Line starts with upper case
Line starts with Upper case
& Line starts with something, then upper case
LINE WITH LOTS OF UPPER CASE
LINE WITH LOTS of UPPER CASE
abcdef
line that preceeds two newlines
line that follows two newlines
/var/nfs/merlin/lpitcher/code/clc $ ./capit <capit.txt
First line of the file, starts with lower case letter
Line with lower case preceeded by whitespace
& another line
%line preceeded by something
Two spaces
Line starts with upper case
Line starts with Upper case
& Line starts with something, then upper case
LINE WITH LOTS OF UPPER CASE
LINE WITH LOTS of UPPER CASE
Abcdef
Line that preceeds two newlines
Line that follows two newlines
/var/nfs/merlin/lpitcher/code/clc $ ./capit <capit.txt >capit.new.txt
/var/nfs/merlin/lpitcher/code/clc $ cat capit.new.txt
First line of the file, starts with lower case letter
Line with lower case preceeded by whitespace
& another line
%line preceeded by something
Two spaces
Line starts with upper case
Line starts with Upper case
& Line starts with something, then upper case
LINE WITH LOTS OF UPPER CASE
LINE WITH LOTS of UPPER CASE
Abcdef
Line that preceeds two newlines
Line that follows two newlines
/var/nfs/merlin/lpitcher/code/clc $