issue: a fopen error occurred: adding "_crt_secre_no_warnings" to the preprocessor
Reference: http://jingyan.baidu.com/article/ce436649fd61543773afd32e.html
Problem: A file read and write was done one afternoon and finally solved: code as follows:
Ifstream myfile ("F:\\1.txt");
Ofstream outfile ("F:\\pdataout.txt", Ofstream::app);
string temp;
if (!myfile.is_open ()) {cout << "file not successfully opened" << Endl; }
while (Getline (myfile, temp, ' \ n ')) {outfile << temp <<endl; } myfile.close (); return 0;
problem: Originally read into a file can not achieve line, think a lot of methods can not achieve, quiet heart to: found with the problem in getline (myfile, temp,' \ n ')) ' \ n ' to achieve the end of the line.
problem : C + + code reads the entire contents of a text file to a string object at one time
Ifstream in ("Readme.txt", ios::in); Istreambuf_iterator<char> Beg (in), end; String Strdata (Beg, end); In.close ();
The entire contents of the Readme.txt can be read into the string object strdata.
problem : Replace all string characters
String::size_type pos = 0;
String s2 = "|";
string s3 = "";
String::size_type a = S2.size ();
String::size_type B = s3.size ();
while (pos = line.find (s2, pos))! = String::npos)
{
Line.replace (POS, 1, S3);
pos + = b;
}
problem: reading a string into the TXT file
outfile << line << Endl;
problem : A problem with the screen flash back
Add # include <stdlib.h> and System ("pause");
problem:C + + cannot find and open PDB files
Tools, Options, general (open source server), open symbol Miscrosoft source server;
If not, add GetChar () or system "pause"
C + + Implementation TXT file read to another TXT file and replace it with a specific character of dictation