Hey, I am trying to make a C++ scrit that decodes and encodes tenis polar (search it on Google if you don't know what it is). After some testing, I found out my application stops after the strcpy. Any help? The code is below. Thanks!
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
void encode(string str);
int main() {
string scode;
cout << "Code: ";
cin >> scode;
encode(scode);
}
void encode(string str) {
char * ccode, * ncode = new char [str.size()+1];
int str_size = str.size()+1;
strcpy (ccode, str.c_str());
for (int i=0; i!=str_size; i++) {
if (ccode[i]=='t') {
ncode[i]='p';
}
cout << ncode;
}
}