我有这一守则,我想读一下文本,并从这一行文中找到独特的代码。 这里,我的文本是:
AGU UACAUU GCG CGA UGG 海湾合作委员会
古阿姆集团
UUA CAU UGCG M GGC CUC GAGAC CGG GUUA AGU AGG UGA
UGG M AAUUU GG CCC AGA GCU CCG GGU AGCG UUA CAU
I want to find the lines that contain the letter M
and make them separate strings so that I can break them up even more and compare them. I am having a little trouble though.
I am trying to find them and the assign it to a string, but it seems to assign all the lines to the same string. This is what I have so far:
ifstream code_File ("example.txt"); // open text file.
if (code_File.is_open()) {
while (code_File.good()) {
getline(code_File,line); //get the contents of file
cout << line << endl; // output contents of file on screen.
found = line.find_first_of( M , 0); // Finding start code
if (found != string::npos) {
code_Assign.assign(line, int(found), 100);
/* assign the line to code_Assign and print out string from where I
found the start code M . */
cout << endl << "code_Assign: " << code_Assign << endl << endl;
ED:我是否应该用扼杀代替分配?