The second Guanjinghan is a character-handling level
View Web page Source code discovery has a large string of characters to deal with, so many characters are not good if put in the source.
So to use the C + + file operation, the header file used is FStream
Here's a reference to this blog post.
For file processing on the opposite string for character type judgment, the judgment of the individual character type (for example, is a letter or a number) to use a lowercase operator function , these functions in the cctype standard library
The function that determines whether a character is a letter is Isalpha ()
Okay, nonsense, no more, second pass:
Purpose: Reads the string inside the text and handles
Solution:
1# include <iostream>2 //# include <math.h>3# include <string>4# include <fstream>5# include <cctype>6 7 usingSTD::string;8 usingstd::cout;9 //using Std::cin;Ten //using Std::endl; One using namespacestd; A - intMain () - { theIfstream infile;//definate fstream - stringTemp//define a var to store strings - -Infile.open ("MyFile.txt");//Open the file + - while(Getline (infile, temp))//Use getline () fuction + { A for(inti =0; I < temp.size (); ++i) at { - if(Isalpha (Temp[i])) - { -cout <<Temp[i]; - } - } in - } to return 0; +}
The difficulties and solutions encountered:
1. Read the file how to read the inside of each line of string instead of multiple "operator, the answer is to use the while loop and Getline function
2. How do I determine the character category? The answer is to use Cctype.
Pythonchallenge's C + + learning Chapter-03