
-----------------------------------
HRI
Wed May 05, 2010 7:22 pm

length() and substr()  Are Messed Up...
-----------------------------------
For class I have to make a program that given a number between 1 and 1000, outputs that many 'moo' numbers which satisfy 2 conditions:
1. It is even.
2. It is a palindrome.

Here's my code, although I've changed it quite a bit to try to make it work. I've also never converted ints to strings before so I'm guessing that's where the problem is. I tried both sstream and itoa. Also, please mention if that break statement won't exit the for loop, as that was my intention.

#include  
using std::cout; //cout is like printf
using std::cin; //cin is like scan or whatever stdio uses
using std::endl; //new line

#include 
using std::string;

#include 
#include 

//I would just put 'using namespace std;', but we're not allowed.

int main()
{
    bool palindrome = false; //initialize the palindrome check to false.
    int i = 1, n; //i is for the current number being checked and n is for how many numbers in total.
    
    cout > n;
    
    for (i = 1; i 