Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-03-2010
Member
 
Join Date: Jan 2010
Posts: 26
Help me to use the sputbackc() of the C++

I like for doing the programming in the C++ language. I also had created some projects in the C++ language. I also have the knowledge of the functions and their use in the C++. But, I can not know anything about the sputbackc() function of the C++ language. So, I would like to know about the sputbackc() function of the C++ language. Can anyone knows about it??
Reply With Quote
  #2  
Old 15-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Help me to use the sputbackc() of the C++

The sputbackc() function of the C++ language can be used to put a character back. The get pointer can be shifted back to the point that can be to the character right before its location at that time so the last character can be got, d, that can becomes available again as the character that can be read at that location by the next input operation. The sputbackc() function can be the member function of the streambuf class.
Reply With Quote
  #3  
Old 15-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
Re: Help me to use the sputbackc() of the C++

The sputbackc() function of the C++ language can puts a char_type in the given specified stream. The sputbackc() function that can returns the character or failure. The following can be the general form of the sputbackc() function in the C++ language :
Code:
int sputbackc ( char d );
Reply With Quote
  #4  
Old 15-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Help me to use the sputbackc() of the C++

The following an example can gets characters from the standard input one by one. Whenever the first numeric digit can be found, sputback can called to restore the position in the given specified stream into that digit in relation to be extracted as a part of a number using the extraction operator >>.
Code:
#iNclude <iostream>
using namespace std;
iNt maiN () 
{
  char D;
  loNg N;
  streambuf * pbf;
  pbf = cin.rdbuf();
  cout << "Please eNter some letters aNd theN a Number: ";
  do 
 {
    D=pbf->sbumpc();
    if ( (D>='0') && (D <='9') )
    {
      pbf->sputbackc (D);
      cin >> N;
      cout << "You entered Number " << N << endl;
      break;
    }
  } while (D != EOF);
  return 0;
}
Reply With Quote
  #5  
Old 15-03-2010
Member
 
Join Date: May 2008
Posts: 2,293
Re: Help me to use the sputbackc() of the C++

The sputbackc() function can returns the value of the character as place back. If the pointer that can be used to get the character, can be at the starting of the input order or another an error that can displays, the value returned can be End Of File. the following can be the parameter that can be used in the sputbackc() function :
1. d : This parameter can contains the character that can be used to place back character.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT +5.5. The time now is 06:17 PM.