upper.cpp


#include <ctype.h>
#include <iostream>
using namespace std;

// main routine to test upper() function
// use member functions of standard input/output objects

char upper(char);	//function prototype
int main()
{
	char c, uc;
	while (cin.get(c) != 0)	//use cntl z to exit
	{
		uc = upper(c);
		cout.put (uc);
	}
	cout.flush();
	return 0;
}


char upper(char c)
{
	if (islower(c) )	// if c is lower case—islower() is a function from ctype.h
	{

		return (char) toupper(c);	/*make it upper case—toupper is a function from 				ctype.h*/
	}
	else

		return c;		//don't change c
}


Results

C:\classes\ece538\work>upper
Here we go
HERE WE GO
^Z


Maintained by John Loomis, updated Sun Dec 31 17:21:22 2006