Thread: errors may b concerning strings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    164

    errors may b concerning strings

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main()
    {
    	string letters = "Madam I'm Adam";
    	size_t length = letters.length();
    	bool isPalindrome;
    	unsigned index = 0;
    	string testStr;
    	
    	// Lowercase all the characters
    	// extract the letters without including punctuation and spaces
    	while (index < length)
    	{
    		if (isalpha(letters[index]))		
    			testStr += tolower(letters[index]);
    
    		index++;
    	}
    
    	// Now check if it is a palindrome
    	isPalindrome = true;
    	for (int i = 0; i < (testStr.length() / 2); i++)
    	{
    		if (testStr[i] != testStr[testStr.length() - (i-1)])
    		{
    			isPalindrome = false;
    			break;
    		}
    	}
    	cout << "\"" << letters << "\"" << isPalindrome ? "is" : "is not"
    		 << " a palindrome." << endl;
    
    	return EXIT_SUCCESS;
    
    }
    I can get it to compile due to some errors which I'm unable to understand, I'm compiling it with Visual Studio 2005

    The build log is

    EDIT:

    Got it. Was using C++/CLI so, had forgotten the parenthesis

    but still there are two errors

    Code:
    1>------ Build started: Project: C++ConsoleTest, Configuration: Debug Win32 ------
    1>Compiling...
    1>test.cpp
    1>c:\documents and settings\manzoor\my documents\visual studio 2005\projects\c++consoletest\c++consoletest\test.cpp(25) : warning C4018: '<' : signed/unsigned mismatch
    1>c:\documents and settings\manzoor\my documents\visual studio 2005\projects\c++consoletest\c++consoletest\test.cpp(34) : error C2296: '<<' : illegal, left operand has type 'const char [7]'
    1>c:\documents and settings\manzoor\my documents\visual studio 2005\projects\c++consoletest\c++consoletest\test.cpp(34) : error C2297: '<<' : illegal, right operand has type 'const char [15]'
    1>Build log was saved at "file://c:\Documents and Settings\manzoor\My Documents\Visual Studio 2005\Projects\C++ConsoleTest\C++ConsoleTest\Debug\BuildLog.htm"
    1>C++ConsoleTest - 2 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Well, it would be great if told how to resolve the warning
    Last edited by manzoor; 09-09-2008 at 05:35 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-29-2009, 10:13 AM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 12:28 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM