Hey,
I am writing a palindrome app for a class. I'm having a problem though using size() or length() for the string lengths. I keep getting a typecast error but I am almost sure I am writing it correctly (I have searched the boards, read the FAQ, and looked in my book). I see multiple examples written this way:
On compile I get the following error:Code:#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string s;
int x;
cout << "Enter a string:" << endl;
cin >> s;
x = s.size();
cout << endl << "The string " << s << " is " << x << " characters long." << endl;
return 0;
}
Im using Visual Studio 7.0. I know it's just a warning but is there anyway to make it right?Code:c:\Documents and Settings\Josh\My Documents\Visual Studio Projects\strings\strings\strings.cpp(13) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
Thanks,
Joshua Norton