Posted by nukedclx on Sun 6th May 04:20
download | new post
- #include <iostream>
- #include <fstream>
- using namespace std;
- string strtolower(char str[255])
- {
- char tmp[255];
- for(int i=0;i<=strlen(str);i++) { tmp[i] = (char)tolower(str[i]); }
- return tmp;
- }
- string strtoupper(char str[255])
- {
- char tmp[255];
- for(int i=0;i<=strlen(str);i++) { tmp[i] = (char)toupper(str[i]); }
- return tmp;
- }
- int main(int argc, char *argv[])
- {
- if (argc!=4)
- {
- cout
- << "\nconvert file data into lower/upper letters" << endl << endl
- << "Usage: " << argv[0] << ".exe <options> <file> <outfile>"
- << "Options:" << endl
- << " --tolower" << endl
- << " --toupper" << endl
- << "example: cl.exe --tolower inputfile.txt outfile.txt" << endl << endl
- << "writen by nukedclx (nukedclx [at] gmail.com)" << endl;
- exit(1);
- }
- ofstream plikzor;
- plikzor.open(argv[3]);
- ifstream src;
- src.open (argv[2],ifstream::in);
- char tmp[255];
- int lines = 0;
- while(!src.eof())
- {
- src.getline(tmp,255);
- if (strstr(argv[1],"--toupper")!=NULL) { plikzor << strtoupper(tmp) << endl; }
- if (strstr(argv[1],"--tolower")!=NULL) { plikzor << strtolower(tmp) << endl; }
- lines++;
- }
- src.close();
- plikzor.close();
- }
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.