-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileIO.cpp
56 lines (48 loc) · 975 Bytes
/
fileIO.cpp
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
55
// Chapter 10, Programming Challenge 15. This program
// will analyse the characters of a file
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
int main()
{
// Variables
int uCase = 0, lCase = 0, dgt = 0, count = 0;
ifstream inputFile;
bool upper = false;
bool lower = false;
bool digit = false;
bool valid = false;
char characters;
inputFile.open("C:\\temp\\text.txt");
if (!inputFile)
cout << "File open failure!\n";
else
{
// Analyses file
while (inputFile >> characters)
{
if (isupper(characters))
{
upper = true;
uCase++;
}
if (islower(characters))
{
lower = true;
lCase++;
}
if (isdigit(characters))
{
digit = true;
dgt++;
}
}
}
inputFile.close();
// Dispaly informations about characters inside file
cout << "Uppercase characters: " << uCase << endl;
cout << "Lowercase characters: " << lCase << endl;
cout << "Digits: " << dgt << endl;
return 0;
}