Hi, I'm trying to write a program(beginner level) to read a text file line by line and compare each character with one in my code. So far I have read the lines from the file:
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main() {
vector<string> v;
ifstream in("textfile.txt");
string line;
while(getline(in, line))
v.push_back(line); // Add the line to the end
// Add line numbers:
for(int i = 0; i < v.size(); i++)
cout << i << ": " << v << endl;
}
and added line numbers, but now I would like to compare the individual charatcters in each line.
For example, line 10 is : "This is line ten (10)"
How do I check that the number inseide the brackets is "10" and let the sentence print if true? ( and repeat for all lines)
Appreciate any help, thanks!