home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
msj
/
v10n05
/
dqa0595.exe
/
UPCASE.C
< prev
Wrap
C/C++ Source or Header
|
1995-05-01
|
1KB
|
45 lines
/*
* Trivial MS-DOS program that converts all the lowercase characters
* in a text file to uppercase.
*/
#include <stdio.h>
#include <malloc.h>
#define BUFFERSIZE 0x4000
main (int argc, char *argv[])
{
FILE *file;
char *buffer;
int i, count;
char ch;
if (argc == 1)
return 0; /* Nothing to do */
if ((buffer = malloc (BUFFERSIZE)) == NULL)
return -1; /* Memory allocation failed */
if ((file = fopen (argv[1], "r+b")) == NULL) {
free (buffer);
return -1; /* File open failed */
}
while ((count = fread (buffer, 1, BUFFERSIZE, file)) != 0) {
for (i=0; i<count; i++) {
ch = buffer[i];
if ((ch >= 0x61) && (ch <= 0x7A))
buffer[i] -= 0x20;
}
fseek (file, -((long) count), SEEK_CUR);
fwrite (buffer, 1, count, file);
fseek (file, 0, SEEK_CUR);
}
fclose (file);
free (buffer);
return 0;
}