-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommond_line.cpp
More file actions
44 lines (40 loc) · 1.1 KB
/
commond_line.cpp
File metadata and controls
44 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <cctype>
#include <string>
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Command-line Argument missing " << std::endl;
return 0;
}
else if (argc == 2)
{
if (strcmp(argv[1], "toupper") == 0)
{
std::string str;
std::cout << "Enter the string ";
std::cin >> str;
for (int i= 0; i < str.length(); i++)
{
str[i] = toupper(str[i]);
}
std::cout << "The string is now " << str
<< std::endl;
}
else if (strcmp(argv[1], "tolower") == 0)
{
std::string str;
std::cout << "Enter the string ";
std::cin >> str;
for (int i= 0; i < str.length(); i++)
str[i] = tolower(str[i]);
std::cout << "The string is now " << str
<< std::endl;
}
else
std::cout << "Unmatched second command-line argument"
<< std::endl;
}
return 0;
}