convertion

Alright is their a way to make it wear when the program get the user's name it turn all the lowercase letters to upper then writes it in the file, then the same process just take all uppercase letters and tern them into lowercase to display them back.

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
45
46
47
48
49
50
51
52

	

#include <iostream> 
#include <string>
#include <fstream>
#include <time.h>

using namespace std;

string name;
string input();
void File_Base();


int main()
{
	do{
	input();
        Time();
	help();
	}
	while(one!= "#");
	return 0;
}

string input()
{
	getline(cin,name,'\n');
	return name;
}

void File_Base()
{

	fstream inout;
	inout.open("File_Base.txt",ios::out|ios::app);
	inout<< one <<endl;
	inout.close();
}
void Time()
{
 time_t rawtime;
  struct tm * timeinfo;
  time (&rawtime);
  timeinfo = localtime (&rawtime);

	fstream inout;
	inout.open("File_Base.txt", ios::out|ios::app);
	inout << '\n' << asctime(timeinfo) <<endl;
	inout.close();
}
Last edited on
Easiest way is to iterate over the string and call one of these:
http://www.cplusplus.com/reference/cctype/toupper/
http://www.cplusplus.com/reference/cctype/tolower/

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
#include <cctype>

int main()
{
	std::string str = "Hello World!";
	for (char& ch : str)
		ch = std::toupper(ch);
	std::cout << str;
}
HELLO WORLD!
Nice Alright thank you so much it works great ^^
Topic archived. No new replies allowed.