Question
Instruction As stated above, getline() grabs whatever it can and puts it into the string. You need to check to make sure you get all
Instruction
As stated above, getline() grabs whatever it can and puts it into the string. You need to check to make sure you get all of the fields you expect to get. You need to do this with the string stream
The string stream is exactly like fin or cin. If you use the extractors '>>', it will return true if it is able to put good values in every variable you extract, or return false if it cannot.
For example: if (sin >> a >> b >> c) will only return true if a, b, and c get good and correct data in ALL three a, b, and c. If even one of them fails, the entire statement returns false.
You can use this to make sure you get good data
In the box below, extract number, decimal, and text in that order using the variables already declared for you with the same names
If you cannot get good data in all three, output "Bad Data: XXXXXX " and replace XXXXXX with the actual line you got from getline()
CODE I HAVE WRITTEN :
if(sin >> number >> decimal >> text){
cout
}
else{
cout
}
I NEED TO FIX THIS CANNOT USE THE ELSE, BECAUSE THERE IS AN ELSE BELOW IN CODE THAT I CANNOT EDIT
Instruction The following code has been written for you. THIS CANNOT BE CHANGED PLEASE DO NOT EDIT ANYTHING BELOW THIS POINT
else { cout
this is what I get without trying to code for the "Bad Data part"
Please help
result Result Your Output Input cmd line arg Got: 11737 22.127 Hello Got: 11737 22.13 Hello Got: 22 0.127 3333 Got: 22 0.13 3333 Got: 12 3.17 Gorp Got: 22 0.13 3333 Bad Data: Gosh Darn Me Got: 12 3.17 Gorp stdin 11737 22.127 Hello 22.127 3333 129 Gosh Darn Me 12 3.17 Gorp
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started