Hi everyone.
I'm extremely new to this. It's my first programming course, period. I realize I probably needed a load of pre-reqs, but for some reason, I was advised to take Intro to C++ so...
So far, I've been doing well! However, this latest project has me stumped...
The jist of it:
Read lines from an input file, reverse, compare, find palindrome, and write it back out to the input file.
So far:
#include<fstream>
#include<iostream>
#include<string>
#include<cctype>
usingnamespace std;
#define SIZE 80
char palinCan[SIZE+1];
char reverse[SIZE+1];
int i = 1,a = 0, j ,q = 0,num = 0;
char reversal(char palinCan[SIZE]);
char b;
int main()
{
//int palindrome(char[]);
ifstream in;
ifstream infile;
infile.open("file.txt.txt", ios::in);
if (infile.fail())
{
cerr << "Couldn't open file..." << endl;
return 0;
}
do{
infile.getline(palinCan, SIZE+1);
strcpy_s(reverse, palinCan);
/* if(palindrome(reverse))
cout << storage << reverse << "It's a palindrome" << endl;
else
cout << "Nope" << endl; // I am getting "does not evaluate to function taking #of arguments here */
cout << palinCan << reverse << endl;
}while (!infile.eof());
}
char reversal()
{
for(j = strlen(palinCan); j >= 0 ; j--){
cin >> reverse[SIZE];}
return reverse[SIZE];
}
I don't know how to make a functioning... function to reverse the loop and return the result into the reversal array for comparison. I've tried a few variations, but none of them worked.
Once I have the reverse of the string stored in the reverse array, I should be able to make a comparison function with it, and have it return a simple true or false.
I appreciate any help...