Last active
January 21, 2016 02:29
-
-
Save jkwill87/6c72e4db97dffdc7d0b5 to your computer and use it in GitHub Desktop.
CIS2500 - lab 01 - uppercase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "uppercase.h" | |
int main(int argc, char** argv) { | |
FILE* textFile; | |
char text[BUFFER]; | |
/* Open text file */ | |
textFile = fopen(argv[1], "r"); | |
if (textFile) { | |
fgets(text, BUFFER, textFile); | |
} else { | |
printf("Could not open text file. Exiting."); | |
return (1); | |
} | |
/* Print text before transformation */ | |
printf("Text Before:\n"); | |
printf("%s\n", text); | |
/* Transform text, print results */ | |
uppercase(text); | |
printf("Text After:\n"); | |
printf("%s\n", text); | |
return 0; | |
} | |
void uppercase(char text[]) { | |
char currentChar; | |
int i = 0; | |
do { | |
currentChar = text[i]; | |
if (currentChar >= 'a' && currentChar <= 'z') { | |
text[i] -= 32; | |
} | |
i++; | |
} while (text[i]); | |
fclose(textFile); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __JWILLI19__HELLO__ | |
#define __JWILLI19__HELLO__ | |
#define BUFFER 500 | |
void uppercase(char text[]); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment