-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminusculas.cpp
More file actions
54 lines (48 loc) · 1.29 KB
/
Copy pathminusculas.cpp
File metadata and controls
54 lines (48 loc) · 1.29 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
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in_file;
in_file.open("the_king_james_bible.txt");
if (!in_file) {
cout << "No obert..." << endl;
return 1;
}
ofstream out_file;
out_file.open("kingjamesbible.txt");
if (!out_file) {
cout << "No obert segon..." << endl;
return 1;
}
char ch;
while ( !in_file.eof() && !in_file.fail() && !out_file.fail() )
{
in_file.get(ch);
if(ch < 128)
{
if ( (ch >= 'A') && (ch <= 'Z') )
ch = ch | 0x20;
out_file.put(ch); // Forzado de minusculas
}
else if (ch == 0xC3)
{
out_file.put(ch);
in_file.get(ch);
out_file.put( (ch | 0x20) ); // Suponemos que solo tenemos vocales y ñ
}
else {
cout << "Error de cribratge. Valor char: "<< (unsigned int) ch << endl;
}
}
if(in_file.bad()){
cout << "Error lectura in_file" << endl;
}
if (out_file.bad())
{
cout << "Error escritura out_file" << endl;
}
out_file.close(); in_file.close();
cout << endl << "Files closed. Fin de programa" << endl;
return 0;
}