Oct 11, 2018 at 3:21pm UTC
i have had a look and i cant see any functions that would replace putback and peek, can you tell me which functions i can use to replace them? Thanks.
Oct 11, 2018 at 3:30pm UTC
I have never used putback() or peek().
How could I possibly know what your program does?
If I don't know that, how could I know what are equivalent solutions?
Oct 11, 2018 at 3:38pm UTC
it replaces a hash with a dollar sign multiple times in a sentence.
Oct 11, 2018 at 4:22pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
using std::cin;
using std::cout;
int main()
{
char ch;
bool first = true ;
cout <<"Enter a phrase: " ;
while ( cin.get( ch ) )
{
if ( ch == '!' ) cout << '$' ;
else if ( ( ch == '#' && first ) || ch != '#' ) cout << ch;
first = false ;
}
}
Enter a phrase: # abc d! e# f##
# abc d$ e f
Last edited on Oct 11, 2018 at 4:25pm UTC