Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 05-29-2005, 12:42 PM   #1 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
hope this is ok here , VC++ linker error, but works in Gcc and dev_c++

I have this now working program (as long as its compiled in gcc or dev-c++)
but for testing I try Vc++ V6 to make sure others can compile (im tring to create a habit)

Vc++ gives this error
error C2665: 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' : none of the 7 overloa
ds can convert parameter 1 from type 'class std::reverse_iterator<char *,char,char &,char *,int>'
Error executing cl.exe.


and this is the line it points to
Code:
if (  SetToTest == string(SetToTest.rbegin(), SetToTest.rend()) )
here is the entire program
Code:
//extra credit
#include<iostream>
#include<cctype>
#include<string>

using namespace std;

//function prototypes
void clear_screen();
string Check (const string& );
string make_lower(const string& );
string check_Punctuation(const string& , const string& );


//main function
int main()
{
	//local varables
 	char LineToCheck[255];
      	string TestInput,SetToTest;
	
	
	clear_screen();
	//get input and hold it in char LineToCheck, convert to string to edit and check
	cout << "Enter Line that could be a palendrome:" << endl;
	//get input in form required can recive up to 255 char
	cin.get(LineToCheck,255);
	
	//place input into string to process
	TestInput = LineToCheck;
	
	SetToTest = Check(TestInput);
	
	//compair original input - punctuation and capitialization aginst 
	//input reverst using the inherent string class reverses
	if (  SetToTest == string(SetToTest.rbegin(), SetToTest.rend()) )
	cout << "your input is a palendrome" << endl;
	
	else
	cout << "your input is not a palendrome" << endl;
	
	return 0;
}	        
	
//------Clear Screen--------------------------------------------------------
void clear_screen()
{
#if defined WIN32
system ("cls");
#elif defined UNIX
system ("clear");
#endif
}
//------Check loop----------------------------------------------------------
string Check (const string& s)
{
//create loop local strings
string punctuation(",;:.?!'\" ");
string TestString;
string LowerCheck (s);

//make all char lower case
LowerCheck = make_lower(LowerCheck);
//remove puctuation
TestString = check_Punctuation(punctuation, LowerCheck);

return TestString;
}

//------make lower case-----------------------------------------------------
string make_lower(const string& s)
{
    string holder(s); 
    for (int i = 0; i < s.length( ); i++)
        //tolower is part of the cctype lib returns lowercase version of c if there is one,
	// otherwise it returns the character unchanged.
	holder[i] = tolower(s[i]);

    return holder;
}

//remove Punctuation funtion
string check_Punctuation(const string& punct, const string& Holder)
{
    //funtion only string
    string no_punctuation; 
    //set variables to hold length of string for loops
    int holder_length = Holder.length( );
    int punct_length = punct.length( );

    for (int i = 0; i < holder_length; i++)
    {
         //create a 1 char string to hold the test canadate
	 string SingleChar = Holder.substr(i,1); 
         //Find location of successive characters that are in string punct that 
	 int locationOfChar = punct.find(SingleChar, 0);
         
      // SingleChar not in punct, so keep it
      if (locationOfChar < 0 || locationOfChar >= punct_length)
         no_punctuation = no_punctuation + SingleChar; 
    }

    return no_punctuation;
}

if it matters VC++ in ran from xp in Vmware form my Gentoo box.. I don't believe this matters .. but I have seen stranger things.

thanks for your help
iccaros is offline   Reply With Quote
Old 05-30-2005, 11:57 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I don't know exactly what the problem is for VC but mind that the std::string provided by this ancient MS environment is very buggy. Usually professional programmers may want to upgrade the STL library to STLPort. The problem is that the whole STL implementation is buggy and out of date with MS VC++ 6.
__________________
Valmont is offline   Reply With Quote
Old 05-30-2005, 06:00 PM   #3 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
ok.. I just need this for 3 more weeks of this class. then I'll use my visual C++.net work bought for me. I was afrade I would have to alot more work to make my stuff crossplatform compatable.
iccaros is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:27 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting