My job is to read in a line of data from an input file, remove all white space and punctuation, then check to see whether or not it is a palindrome. A palindrome is a word or phrase that is the same backwards as it is forward like RACECAR.
The input file is an arbitrary length long including no input. I need to read in a line of data at a time then process it until there is no more data to process.
The output should look something like this.
Input Value: Sit on a potato Pan otis
Is it a palindrome? Yes
Input Value: race car
Is it a palindrome Yes
Input Value: wooHaaaaa
Is it a palindrome? No
I am very new to Programming so anything that you smarter people can do to help me would be greatly appreciated!
This is what I have right now:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
bool isPalindrome(string, int);
int main()
{
string sentence;
bool Palindrome;
int len;
I have this program, but I dont know how to get what I need. I need to read in each line of the input file and check if each line is a Palindrome. it should look something like this:
Input Value: Sit on a potato Pan otis
Is it a palindrome? Yes
I'm very new to programming. Ive been reading my book but I cant figure out how to do a lot of the things that are needed including stripping out the whitespace
@prototype151 That is incorrect. usingnamespace std; allows you to omit the std:: prefix. Including the iostream header is what gives access to std::cout and std::cin in the first place.