-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEXAM001.cpp
More file actions
37 lines (35 loc) · 805 Bytes
/
EXAM001.cpp
File metadata and controls
37 lines (35 loc) · 805 Bytes
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
/**
* @input EXAM001.cpp
* @author long (you@domain.com)
* @brief C++ program to count all characters in a c++ input.
* @version 0.1
* @date 2023-03-10
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#include <fstream>
#include <string>
void removeSpaces(std::string &str)
{
str.erase(remove(str.begin(), str.end(), ' '), str.end());
}
int main() {
std::fstream input, output;
input.open("main.cpp", std::ios::in);
output.open("output.txt", std::ios::out);
std::string line;
int count = 0;
while (!input.eof()) {
getline(input, line);
removeSpaces(line);
count += line.length();
}
getline(input, line);
removeSpaces(line);
count += line.length();
output << count;
input.close();
output.close();
}