I'm Polish, and my English is so poor, but i hope that You help me. I'm trying to write a code for euler-project to reversing and comparing strings. I know, that i can do that by substr, but i'd like to do this on other way.
That's my code:
#include "stdafx.h"
#include "iostream"
#include "String"
#include "sstream"
using namespace std;
int main()
{
string input;
int i, j;
int najwyzsza;
najwyzsza = 0;
ostringstream wynik_s;
for ( int k = 10 ; k < 100 ; k++ )
{
for ( int t = 10 ; t < 100 ; t++)
{
int wynik = t*k;
wynik_s << wynik;
string str = wynik_s.str();
input = str;
const char* p = str.c_str();
char dst[10];
strcpy(dst, p);
cin.get(p);
string output(input.length(), ' ');
for ( i = 0 , j = input.length() - 1 ; i < input.length() ; i++ , j--)
{
output[i]=input[j];
}
if (input == output)
{
cout<<input;
}
cout << "Reversed string = " << output;
}
}
cin.get();
return 0;
}
I'm using MS VS 2010, and i have 2 errors.
First about declaration of 'strcpy',
Second about conversing 'const char *' to 'char &'
I looked a lot about it in the Internet, but i couldn't find anything what could helps me.
Thank you in advance for help,
mati199537

New Topic/Question
Reply



MultiQuote





|