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


C++ istream::ignore方法代码示例

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


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

示例1: receive

bool Order::receive(istream& is){
	bool error = false;
	int a = 0;
	while (!error){
		cout << "Quantity (0  to quit): ";
		is >> a;
		is.clear();
		is.ignore();
		if (!is){
			is.clear();
			is.ignore(2000, '\n');
			cerr << "Error try again" << endl;
		}else if (a == 0){
			error = true;
			cerr << "No delivery recorded" << endl;
			return false;
		}else if (a < 0){
			cerr << "Please enter positive value" << endl;
		}
		else if (a > qtyOrder){
			cerr << a << " not on order.  Only " << qtyOrder << " are on order.  Try again" << endl;
		}else{
			qtyDeliver = qtyDeliver + a;
			return true;
		}
	}
}
开发者ID:Cohaven,项目名称:bookstore,代码行数:27,代码来源:Order.cpp

示例2: setFromKeyboardByName

void Employee::setFromKeyboardByName(istream& in)
{
	string EGN;

	in >> EGN;
	while (!validateEGN(EGN))
	{
		in.clear();
		in.ignore(10000, '\n');
		in >> EGN;
	}
	this->EGN = EGN;

	in.clear();
	in.ignore(1);
	string address;
	getline(in, address);
	this->address = address;

	string hiredWhen;
	getline(in, hiredWhen);
	this->hiredWhen = hiredWhen;

	string boss;
	getline(in, boss);
	this->boss = boss;

	string projectName;
	getline(in, projectName);
	this->projectName = projectName;
}
开发者ID:TAPATOP,项目名称:Human-Resources,代码行数:31,代码来源:Employee.cpp

示例3: atoi

bool t_dir_graph::read_format2(istream& input, const string first_line){
	vector<t_vertex> verts;
	int adj;
	t_vertex v;
	uint datas = atoi(first_line.c_str());

	while(input.peek() == '\n') input.ignore(1); // read the '\n'
	// read vertices
	for(uint i = 0; i < datas; i++){
		input >> v;
		verts.push_back(v);
		while(input.peek() == '\n') input.ignore(1); // read the '\n'
	}
	for(uint i=0; i < verts.size(); i++) insert_vertex(verts[i]);
	// read adjacency matrix
	for(uint i=0; i < verts.size(); i++){
		for(uint j=0; j < verts.size(); j++){
			input >> adj;
			if(adj > 0)
				insert_arc(t_arc(verts[i], verts[j]));
			while(input.peek() == ' ') input.ignore(1); // read the ' '
			while(input.peek() == '\n') input.ignore(1); // read the '\n'
		}
	}
	return true;
}
开发者ID:igel-kun,项目名称:transEd,代码行数:26,代码来源:digraph.cpp

示例4: getCoord

//---------------------------------------------------------------------------------
// Function:	getCoord()
// Title:	Get Coordinates 
// Description:
//		Returns a cell with coordinates set by user
// Programmer:	Paul Bladek
// 
// Date:	9/12/06
//
// Version:	1.0
// 
// Environment: Hardware: i3 
//              Software: OS: Windows 7; 
//              Compiles under Microsoft Visual C++ 2012
//
// Input:	cell coordinates (in the form "A13" from sin
//
// Output:	prompts to cout
//
// Calls:	none
//
// Called By:	main()
//		setships()
//
// Parameters:	sin: istream&;	the stream to read from
//		size: char;	'S' or 'L'
// 
// Returns:	Cell location -- a cell containing the input coordinates
//
// History Log: 
//				9/12/06 PB comleted v 1.0
//				1/20/15 KG % HN completed v 1.1
//     
//---------------------------------------------------------------------------------
Cell getCoord(istream& sin, char size)
{
	cin.clear();
	fflush(stdin);
	short numberOfRows = (toupper(size)=='L') ? LARGEROWS : SMALLROWS;
	short numberOfCols = (toupper(size)=='L') ? LARGECOLS : SMALLCOLS;
	char highChar = static_cast<char>(numberOfRows - 1) + 'A';
	char row  = 'A';
	short col = 0;
	Cell location = {0, 0};
	do
	{
		col = 0;
		cout << "Row must be a letter from A to " << highChar 
			<< " and column must be  from 1 to "  << numberOfCols << ": ";
		while((row = toupper(sin.get())) < 'A' || row  > highChar)
		{
			sin.ignore(BUFFER_SIZE, '\n');
			cout << "Row must be a letter from A to " << highChar 
				<< " and column must be  from 1 to "  << numberOfCols << ": ";
		}
		sin >> col;
		if(!sin)
			sin.clear();
		sin.ignore(BUFFER_SIZE, '\n');
	}
	while(col < 1 || col > numberOfCols);
	location.m_col = col - 1;
	location.m_row = static_cast<short>(row - 'A');
	return location;
}
开发者ID:KyleGraham,项目名称:CS132,代码行数:65,代码来源:fleet.cpp

示例5: set

void Employee::set(istream& in, ostream& out)
{
	string name;
	in.clear();
	in.ignore(1);
	while (true)
	{
		getline(in, name);
		if (validateName(name))
		{
			this->name = name;
			break;
		}
		out << "Try again..." << endl;
	}

	string EGN;


	while (true)
	{
		in >> EGN;
		if (!validateEGN(EGN))
		{
			out << "Inavlid EGN" << endl;
			continue;
		}
		break;
	} 

	this->EGN = EGN;

	in.clear();
	in.ignore(1);
	string address;
	getline(in, address);
	this->address = address;

	string hiredWhen;
	getline(in, hiredWhen);
	this->hiredWhen = hiredWhen;

	string boss;
	getline(in, boss);
	this->boss = boss;

	this->position = (Position)0;

	string projectName;
	getline(in, projectName);
	this->projectName = projectName;
}
开发者ID:TAPATOP,项目名称:Human-Resources,代码行数:52,代码来源:Employee.cpp

示例6: getHtml

vector<tag> getHtml(istream& input, int htmlLines){

    vector<tag> html;
    stack<tag> holdTag;



    for (size_t i = 0; i < htmlLines; i++) {
        tag temp;

        input.ignore(LINESIZE, '<');

        if (input.peek() == '/') {

            tag hold = holdTag.top();
            holdTag.pop();
            if (holdTag.empty()) {
                html.push_back(hold);
            }else{
                holdTag.top().children.push_back(hold);
            }

            input.ignore(LINESIZE, '\n');
        }else{

            holdTag.push(tag());
            input >> holdTag.top().tagName;

            if(holdTag.top().tagName.back() == '>'){
                holdTag.top().tagName.erase(holdTag.top().tagName.end()-1);
                input.unget();
                //remove the last char if the > char is found there
            }

            while(input.peek() != '>'){
                string key, val;
                input.get();
                getline(input, key, ' ');
                input.ignore(LINESIZE, '\"');
                getline(input, val, '\"');
                holdTag.top().attributes.insert(make_pair(key, val));

            }
        }




    }
    return html;
}
开发者ID:jameogle,项目名称:codesnippets,代码行数:51,代码来源:htmlParse.cpp

示例7: run

void run(exploder & e, istream& in)
{
   // any larger, and we may try to write to a multi_frame that never has enough space
   static const int BUF_SIZE = multi_frame::MAX_SIZE - frame::FRAME_SIZE;
   scoped_array<char> buffer(new char[BUF_SIZE]);

   ios::sync_with_stdio(false); // makes a big difference on buffered i/o

   for (int line = 1; !in.eof(); ++line)
   {
      in.getline(buffer.get(), BUF_SIZE - 1); // leave 1 for us to inject back the newline
      if (buffer[0] == '\0')
         continue;
      if (in.fail()) // line was too long?
      {
         cerr << "Skipping line <" << line << ">: line is probably too long" << endl;
         in.clear(); // clear state
         in.ignore(numeric_limits<streamsize>::max(), '\n');
         continue;
      }
      buffer[in.gcount() - 1] = '\n'; // inject back the newline
      buffer[in.gcount()] = '\0';
      e << buffer.get();
   }
}
开发者ID:kyle-johnson,项目名称:spread,代码行数:25,代码来源:explode_app.cpp

示例8: read_func_labeled

//read coefficients from a stream. This assumes pairs of bitstring and values, e.g.
//010100 1.232
//101011 65.432
int hypercube_lowd::read_func_labeled(istream &in)
{
	int i=0, count;
	char gt[dim+2];
	if (in.bad())
	{
		cerr <<"hypercube_lowd::read_func_labeled: bad stream\n";
		return HC_BADARG;
	}
	count=0;
	while(in.good() && count<(1<<dim))
	{
		i=0;
		in >>gt;
		for (int k=0; k<dim; k++)
			if (gt[k]=='1') i+=1<<k;
		in >>func[i];
		count++;
		in.ignore(100, '\n');
	}
	if (count<(1<<dim))
	{
		cerr <<"hypercube_lowd::read_func: file end reached after "<<i<<" values!\n";
		return HC_BADARG;
	}
	return 0;
}
开发者ID:iosonofabio,项目名称:ffpopsim,代码行数:30,代码来源:hypercube_lowd.cpp

示例9: order

/*
 * A modifier that receives a reference to an istream object and increases 
 * the number of copies to be ordered based upon data received from input stream is
 */
int Order::order(istream& is){
    bool flag = false;
    bool continueGoing = true; 
    bool isChanged = false;
    int iStream;

    while (continueGoing){
        cout << "Quantity (0 to quit) : ";
        is >> iStream;
        if (!is){
             is.clear();
             is.ignore(2000, '\n');
             cerr << "Error. Try Again " << endl;
        }
        else if(iStream == 0){
             cerr << "**No delivery recorded!" << endl; 
             continueGoing = false;
        }
        else if(iStream < 0){ 
             cerr << "Enter a positive number.  Try again." << endl; 
        }
        else{
             ordered = ordered + iStream;
             isChanged = true;
             continueGoing = false;
        }  
    }
    if(isChanged) 
        flag = true;
    return flag;
}
开发者ID:hellodarren,项目名称:isbn-reader,代码行数:35,代码来源:Order.cpp

示例10: SkipSpaces

bool SkipSpaces (istream& is, Coordinates& xy, Coordinates& pos)
{
	while (is.peek() == ' ' || is.peek() == '\n' || is.peek() == '\t' || is.peek() == '{')
	{
		if (is.peek() == '{')
		{
			char c='{';
			pos = xy;
			while (c != '}')
			{
				c = GetSymb(is, xy);
				if (c == EOF)
					return false;
			}
		}
		if (is.peek() == '\n')
		{
			xy.first = 1;
			++xy.second;
		}
		else
			if (is.peek() == '\t')
				xy.first += 8;
			else
				++xy.first;
		is.ignore();
	}
	return true;
}
开发者ID:ValeevaDA,项目名称:compiler-236,代码行数:29,代码来源:scanner.cpp

示例11: password_command

static void password_command(ostream &out, istream &in)
{
   char username[200] ;
   char oldpwd[200] ;
   char newpwd[200] ;
   
   out << "User name: " << flush ;
   in.ignore(1000,'\n') ;
   in.getline(username,sizeof(username)) ;
   out << "Old password: " << flush ;
   in.getline(oldpwd,sizeof(oldpwd)) ;
   out << "New password: " << flush ;
   in.getline(newpwd,sizeof(newpwd)) ;
   FrStruct *userinfo = retrieve_userinfo(username) ;
   if (!userinfo)
      {
      cout << "Unknown username!" ;
      return ;
      }
   if (set_user_password(oldpwd,newpwd,userinfo))
      {
      cout << "Successfully set password." << endl ;
      if (!store_userinfo())
	 cout << "....but error updating user information file!" << endl ;
      }
   else
      cout << "Password update failed!" << endl ;
}
开发者ID:tripleee,项目名称:la-strings,代码行数:28,代码来源:test.C

示例12: while

bool SquareMaze::SquareMazeNode::readXY (istream& inData,int *x,int *y)
{
  char ch;
  // skip leading spaces, which are legit
  while (1) {
    inData.get(ch);
    if (ch!=' ') {
      break;
    }
  }
  if (ch!='(') {
    // not valid - probably a newline
    return false;
  }

  inData >> *x;
  if (inData.fail()) {
    inData.clear();
    cout << "WARNING: Solution seems to have a bad format\n";
    // a bit of random, defensive programming
    inData.ignore(100000,'\n'); // make sure we don't just keep reading the same thing
    return false;
  }
  inData.get(ch);
  inData >> *y;
  inData.get(ch);

  return true;
}
开发者ID:richlum,项目名称:BFmazerunner,代码行数:29,代码来源:SquareMaze.cpp

示例13: StreamIn

void MidiPlugin::StreamIn(istream &s) 
{
	int version;
	s>>version;
		
	switch (version)
	{
		case 1:	s>>m_DeviceNum>>m_NoteCut; break;
		
		case 2:
		{
			s>>m_DeviceNum>>m_NoteCut; 
			
			int Num;
			s>>Num;
			
			for (int n=0; n<Num; n++)
			{
				int Control;
				s>>Control;
				
				char Buf[4096];	
				int size;		
				s>>size;
				s.ignore(1);
				s.get(Buf,size+1);								
				
				AddControl(Control, Buf);
			}			
		}
	}
}
开发者ID:sdekrijger,项目名称:spiralsynthmodular,代码行数:32,代码来源:MidiPlugin.C

示例14: read

void simulator::read(istream &in){
	const size_t n=input.size(), p=input[0].size()-1, s=result[0].size();

	for(size_t K=0; K<n; ++K){
		for(size_t L=0; L<p; ++L){
			in >> input[K][L];
			in.ignore(); //csv o ssv funciona
		}
		input[K][p] = 1; //entrada extendida
		
		for(size_t L=0; L<s; ++L){
			in >> result[K][L];
			in.ignore(); //csv o ssv funciona
		}
	}
}
开发者ID:fvictorio,项目名称:inteligencia_computacional,代码行数:16,代码来源:simulator.cpp

示例15: rmuser_command

static void rmuser_command(ostream &out, istream &in)
{
   if (get_access_level() < ADMIN_ACCESS_LEVEL)
      {
      cout << "You must be logged in with administrator privileges\n"
	      "(access level " << ADMIN_ACCESS_LEVEL
	    << " or higher) to add users." << endl ;
      return ;
      }
   char username[200] ;

   out << "Name of user to remove: " << flush ;
   in.ignore(1000,'\n') ;
   in.getline(username,sizeof(username)) ;
   if (!retrieve_userinfo(username))
      {
      cout << "No such user!" ;
      return ;
      }
   if (remove_user(username))
      cout << "User information file updated." << endl ;
   else
      cout << "User information file update failed!" << endl ;
   return ;
}
开发者ID:tripleee,项目名称:la-strings,代码行数:25,代码来源:testfp.C


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