请问一个文件输入流字符操作的有关问题

请教一个文件输入流字符操作的问题!

在文件输入输出操作中,有没办法对输入过程特定的字符串进行操作吗??如发现输入字符串是<text>,
跳过当前这个单词。
ifstream in("test1.txt");  
while(in>>vocabulary)  
{
  if (vocabulary=="<text>")
  {
  //跳过当前的单词
  }
   
};

------解决方案--------------------
好象有个是
getlines之类的。可以根据特别码识别。

不过你这个程序只要这样改下就好了

ifstream in("test1.txt");
int i=0; 
while(in>>vocabulary[i]) //假设vocabulary是个数组
{
 
if (vocabulary==" <text>")
{
//跳过当前的单词
continue;
}
++i
//其他操作
};
------解决方案--------------------
getline是读取整行的,一般不能这么做

楼主可以试试下面的方法:
ifstream in("test1.txt");
char* str;
char* src = "<text>";
while(in>>str)

 
if (strcmp(str, src) == 0) 

//跳过当前的单词 
continue; 

//其他操作 
};
------解决方案--------------------

C/C++ code

ifstream   in("test1.txt");  
const string word[3] = {"xxxx","xx","xxxx"};
string inword;  
string article = "";
   
while(in>>inword)                  
{ 
   for(int i = 0; i < 3; i++) {
     if (inword!=word1) 
     { 
        article += inword; 
      } 
   }    
};