How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask ATLProg Your Own Question
ATLProg
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 9151
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
44910485
Type Your Homework Question Here...
ATLProg is online now
A new question is answered every 9 seconds

Read characters into a char Array until the character p is

This answer was rated:

Read characters into a char Array until the character 'p' is encountered, up to a limit of 10 characters (including the terminating null character). Extract the delimiter 'p' from the input stream and discard it

#include "stdafx.h"
#include
#include
#include

using namespace std;

int main()
{

char characterArray[10];
char p;
int ArrayPos = 0;

//read a string into character array 10 characters
cout <> characterArray;


while(ArrayPos <= 10){

//if the character is a p, we need to get rid of it.
if(cin.peek() == 'p')
{
//extract the delimiter from the stream


ArrayPos = 11; //exit loop

}
else
{
characterArray[ArrayPos] = cin.get();
ArrayPos++;
}

}

cout << characterArray << endl;






system("pause");

return 0;


}

Getting garbage displayed on the screen after p is encountered.
Hi I can assist you will have solution ready soon
Customer: replied 4 years ago.

Ok, good. What's the problem?

Customer: replied 4 years ago.

Hello?

THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
ATLProg and other Homework Specialists are ready to help you
How does it look. please remember to rate

Related Homework Questions