当前位置: 首页>>代码示例>>C++>>正文


C++ ifstream::clear方法代码示例

本文整理汇总了C++中ifstream::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ifstream::clear方法的具体用法?C++ ifstream::clear怎么用?C++ ifstream::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ifstream的用法示例。


在下文中一共展示了ifstream::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newGame

void GUI::newGame(){
	fin.close();
	fin.clear();
	delete env;
	delete agent;
	delete evaluator;

	fin.open(file_name_input);
	if(fin){
		current_time=0;
		env=new Environment(fin);
		evaluator=new Evaluator(env);
		agent=new Agent();
        dirty_degree = evaluator->DirtyDegree();
        consumed_energy = evaluator->ConsumedEnergy();

		agente_reactivo_btn->enable();
		display_btn->disable();
		busqueda_profundidad_btn->enable();
		busqueda_anchura_btn->enable();
		escalada_btn->enable();
        busqueda_coste_btn->enable();
	}
	else{
		fin.clear();
		char temp[1000]={"map/"};
		strcat(temp,file_name_input);
		fin.open(temp);
		if(fin){
			current_time=0;
			env=new Environment(fin);
			evaluator=new Evaluator(env);
			agent=new Agent();
            dirty_degree = evaluator->DirtyDegree();
            consumed_energy = evaluator->ConsumedEnergy();


			agente_reactivo_btn->enable();
			display_btn->disable();
		    busqueda_profundidad_btn->enable();
			busqueda_anchura_btn->enable();
			escalada_btn->enable();
            busqueda_coste_btn->enable();
		}
		else{
			agente_reactivo_btn->disable();
			display_btn->disable();
		    busqueda_profundidad_btn->disable();
			busqueda_anchura_btn->disable();
            busqueda_coste_btn->disable();
			escalada_btn->disable();
			error_glui=GLUI_Master.create_glui("Error",0,100,100);
				char error_message[1000]="File ";
				strcat(error_message,file_name_input);
				strcat(error_message," can't be open");
				new GLUI_StaticText(error_glui,error_message);
				new_map_ok_btn=new GLUI_Button(error_glui,"OK",ERROR_OK_BTN_ID,control_cb);
		}
	}
}
开发者ID:jmtorrespalma,项目名称:VacuumCleaner,代码行数:60,代码来源:GUI.cpp

示例2: getSize

//private function called by load(). Passed parameter is the file (ifstream) as imported by load()
//returns integer of number of columns and rows. Returns negative value if invalid grid
int Grid::getSize(ifstream& sourceFile)
{
	int puzSize=0, rowLength;
	string tempString;

	//count how many rows of text
	while(sourceFile.good()){
		getline(sourceFile, tempString);
		puzSize++;
	}
	
	sourceFile.seekg(0,ios::beg);	//move cursor back to beginning
	sourceFile.clear();				//clear error flags
	
	//go through each line again, checking there are the right number of columns in each row
	while(!sourceFile.eof()){
		getline(sourceFile, tempString);
		rowLength = tempString.length();
		if(rowLength!=puzSize){ //if # of columns does not match # of rows
			cout << "Wrong number of columns in this row: "<<tempString<<endl;
			return -1; //if there is a problem, return negative number (and exit)
		}
	}
	sourceFile.seekg(0,ios::beg);	//when finished, make sure to leave cursor at beginning of file
	sourceFile.clear();				//clear error flags
	return puzSize;
}
开发者ID:teekers,项目名称:crossword-generator,代码行数:29,代码来源:Grid.cpp

示例3: sprawdz_baze

size_t sprawdz_baze(ifstream &baza_pytan){
    if( !baza_pytan.good() )  {cout << "bazaZla\n"; return -1;}
    baza_pytan.clear();
    baza_pytan.seekg(0, ios::beg);
    baza_pytan.unsetf(std::ios_base::skipws);
    size_t line_count = count(istream_iterator<char>(baza_pytan),istream_iterator<char>(), '\n');
    baza_pytan.clear();
    baza_pytan.seekg(0,ios::beg);
    return line_count;
}
开发者ID:murnko,项目名称:autoscore,代码行数:10,代码来源:funkcje.cpp

示例4: FileSize

size_t FileSize(ifstream& is) {
  const streampos pos = is.tellg();
  is.clear();
  is.seekg(is.beg);
  is.ignore(numeric_limits<streamsize>::max());
  const size_t size = is.gcount();
  is.clear(); //clear EOF (set by ignore)
  is.seekg(pos);
  return size;
}
开发者ID:ugovaretto,项目名称:zmq-scratch,代码行数:10,代码来源:file-send.cpp

示例5: beginScheduling

void beginScheduling(Scheduling& task, list<Process>& proc,ifstream& file, string& schFileName){
	openFile(file,schFileName);
	readResource(file,task);
	file.clear();
	file.close();
	openFile(file,task.ProcFile);
	getProcesses(file,proc);
	file.clear();
	file.close();
}   
开发者ID:GoodBoyNYC,项目名称:ProjectScheduling,代码行数:10,代码来源:Process+Scheduling.cpp

示例6: openBinaryFile

bool openBinaryFile(string s, ifstream& BIT)
{
  BIT.open(s.c_str(), ios::in|ios::binary);

  char ch[1];
  BIT.read(ch,1);
  bitset<8> b;
  
  b = ch[0];
  bool bfile_SNP_major = false;
  bool v1_bfile = true;
  
  if((b[2]&&b[3]&&b[5]&&b[6]) &&
     !(b[0]||b[1]||b[4]||b[7]))
    {
      BIT.read(ch,1);
      b = ch[0];
      if((b[0]&&b[1]&&b[3]&&b[4])&&
	 !(b[2]||b[5]||b[6]||b[7]))
	{
	  BIT.read(ch,1);
	  b = ch[0];
	  if(b[0]) bfile_SNP_major = true;
	  else bfile_SNP_major = false;
	  
	} else v1_bfile = false;
    } else v1_bfile = false; //end of if b....
  
  if(!v1_bfile)
    {
      BIT.close();
      BIT.clear();
      BIT.open(s.c_str(), ios::in|ios::binary);
      BIT.read(ch,1);
      b = ch[0];
    }

  if((!v1_bfile)&&(b[1]||b[2]||b[3]||b[4]||b[5]||b[6]||b[7]))
    {
      bfile_SNP_major = false;
      BIT.close();
      BIT.clear();
      BIT.open(s.c_str(), ios::in|ios::binary);
    }
  else if(!v1_bfile)
    {
      if(b[0]) bfile_SNP_major = true;
      else bfile_SNP_major = false;
    }

  return bfile_SNP_major;
}
开发者ID:xiangdiuxiu,项目名称:ZhangYet,代码行数:52,代码来源:readBinData.cpp

示例7: openfiles

/*-------------------------------------------------------
opens files to be used as input and output
Receives: input, output
Returns: nothing
---------------------------------------------------------*/
char openfiles (ifstream &input1, ofstream &output1)
{	
	char infile1[20],
		 outfile1[20];

	// opens the file that will be used as the first input file
	cout << "Enter the name of the first input file to be opened: ";
	cin >> infile1;
	input1.open(infile1, ios::nocreate);
	while (input1.fail())
	{
		input1.clear();
		cout << "Could not open " << infile1 
			 << " please re-enter the file name: " << endl;
		cin >> infile1;
		input1.open(infile1, ios::nocreate);
	}
	
	// opens the file that will be used as the output file
	cout << "Enter the name of output file to be opened: ";
	cin >> outfile1;
	output1.open (outfile1, ios::app);    // creates output file for output

	return infile1[20];
}//end openfiles
开发者ID:itanex,项目名称:PopulationStatistics,代码行数:30,代码来源:lib.cpp

示例8: inicializar

void SpecialStack::inicializar(ifstream& file){
    char str[20];
    string linea;
    if (file.is_open()){
        file.clear();
        file.seekg(4, ios::beg);//coloca el offset donde esta el head del availlist en el header
        file.getline(str, 20, ';');
        linea = str;
        int posDisp = cadena2Int(linea);//aqui toma el head del availlist

        while (posDisp != -1){
            cout << "En SpecialStack::inicializar pos que recibe : " << posDisp << endl;
            file.seekg(offsetRegistro+(sizeRegistro * posDisp ));// se va a la poscion en el archvo que indica posDisp
            file.getline(str, 20, ';');
            linea = str;
            availlist.insert(availlist.begin()+0, posDisp);//agrega la poscion al availlist
            VIPList.agregar(posDisp);//agrega la posicion al VIPList que es la lista ordenada de las posciones en el availlist
            posDisp = siguientePosicionDisponible(linea);
        }
        availlist.insert(availlist.begin()+0, posDisp);
        VIPList.agregar(posDisp);
    } else {
        cerr << "ERROR: no se pudo abrir el archivo para lectura de levantar header" << endl;
    }

}
开发者ID:kevinPinzon,项目名称:Proyecto-Orga,代码行数:26,代码来源:specialstack.cpp

示例9: RunList

//template <class Object>
void RunList(ifstream& stream){
   char iord;
   int number;
   
   //string dummy;
   //getline(stream, dummy);
  
   char dummy[256];
   stream.getline(dummy, 256); 
   
   List<int> list;
   ListItr<int> listItr = list.zeroth();
   
   while(stream >> iord >> number){
      if(iord == 'i'){
      list.insert(number, listItr);
      listItr.advance();
      //cout << "Inserted " << number << endl;
      }
      
      else /*if(iord == 'd')*/{
      list.remove(number);
      //cout << "Deleted " << number << endl;
      }
   }
   
   stream.clear();
   stream.seekg(0, ios::beg); 
}
开发者ID:michaelromero,项目名称:Algorithms_DataStructures_CPP,代码行数:30,代码来源:timetestFront.cpp

示例10: RunSkipList

void RunSkipList(ifstream& stream){
    char iord;
    int number;

    //string dummy;
    //getline(stream, dummy);
    
    char dummy[256];
    stream.getline(dummy, 256);
    
    SkipList<int> skiplist(1,250000);
    while(stream >> iord >> number){
        if(iord == 'i'){
            skiplist.insert(number);
        }
        else{
            skiplist.deleteNode(number);
        }
    }

    stream.clear();
    stream.seekg(0, ios::beg);


}
开发者ID:michaelromero,项目名称:Algorithms_DataStructures_CPP,代码行数:25,代码来源:timetestFront.cpp

示例11: create

void create(ifstream &in)
{
    int i(0);
    string s;
    getline(in, s);
    n = new int (s.size());
    m = new int (1);
    while (getline(in, s)) (*m)++;
    mass = new bool*[(*m)];
    for (; i < (*m); i++)
        mass[i] = new bool[(*n)];
    cout << "m= " << *m << endl;
    cout << "n= " << *n << endl;
    *m = 0;
    in.clear();
    in.seekg(0, ios::beg);
    while (getline(in, s))
        {
            for (i = 0; i<(*n); i++)
                if (s[i] == '+') mass[(*m)][i] = true;
                else
                    mass[(*m)][i] = false;
            (*m)++;
        }
}
开发者ID:SCNya,项目名称:GxP,代码行数:25,代码来源:GxP.cpp

示例12: RunStackAr

void RunStackAr(ifstream& stream){
   char iord;
   int number;
   
   //string dummy;
   //getline(stream, dummy);
  
   char dummy[256];
   stream.getline(dummy, 256);

   StackAr<int> stack(250000);

   while(stream >> iord >> number){
      if(iord == 'i'){
        stack.push(number);
      }
      
      else /*if(iord == 'd')*/{
        stack.pop();
        //cout << "Deleted " << number << endl;
      }
   }
   
   stream.clear();
   stream.seekg(0, ios::beg);
}
开发者ID:michaelromero,项目名称:Algorithms_DataStructures_CPP,代码行数:26,代码来源:timetestFront.cpp

示例13: open_file

void open_file ( ifstream &in, const string &file_name ) {

	in.close();
	in.clear();
	
	in.open ( file_name.c_str() );
}
开发者ID:ShujiaHuang,项目名称:HGPP,代码行数:7,代码来源:utility.cpp

示例14: main

int main()
{
	infile.open("StkQFile1.txt");
	outfile.open("Result.dat");
	Stack stackTest;

	while (infile)
	{
		stackTest.read();
		stackTest.reverse();
		stackTest.print();
		stackTest.clear();
	}
	infile.clear();
	infile.seekg(0);
	outfile.close();
	outfile.open("Full.dat");

	while (infile)
	{
		stackTest.readFull();
	}
	stackTest.reverse();
	stackTest.printFull();

	system("pause");
	return 0;
}
开发者ID:Adam-Novoa,项目名称:AthensAssignments,代码行数:28,代码来源:Stack_Class.cpp

示例15: open

void GrowToolbar::open( ifstream& fp)
{
  int		type;
  int 		end_found = 0;
  char		dummy[40];

  for (;;)
  {
    if ( !fp.good()) {
      fp.clear();
      fp.getline( dummy, sizeof(dummy));
      printf( "** Read error GrowToolbar: \"%d %s\"\n", type, dummy);      
    }

    fp >> type;
    switch( type) {
      case glow_eSave_GrowToolbar: break;
      case glow_eSave_GrowToolbar_grownode_part: 
        GrowNode::open( fp);
        break;
	// case glow_eSave_GrowToolbar_nc: 
        // nc = new GlowNodeGroup( ctx, n_name);
        // nc->open( fp);
        // break;
      case glow_eSave_End: end_found = 1; break;
      default:
        cout << "GrowToolbar:open syntax error" << endl;
        fp.getline( dummy, sizeof(dummy));
    }
    if ( end_found)
      break;
  }
}
开发者ID:ManfredHerrmann,项目名称:proview,代码行数:33,代码来源:glow_growtoolbar.cpp


注:本文中的ifstream::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。