There is such a code:

void Encode(char encode[]){ int ready; for(int i=0;i<strlen(encode);i++){ ready=(int)encode[i]; cout<<ready<<'#'; } 

We enter a string, the program translates each character into an int, and separates them with a '#'

  • For example: enter abc
  • We get: 97 # 98 # 99 #

Need to do the reverse function, tobish

  • we enter: 97 # 98 # 99 #
  • we get: abc

Closed due to the fact that the essence of the question is not clear to the participants Vlad from Moscow , Kromster , aleksandr barakin , user194374, Bald December 20, '16 at 3:50 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • five
    And what is the problem? - Vlad from Moscow

2 answers 2

 #include <iostream> #include <string> #include <sstream> void Decode( int* code, int size ){ for( int i( 0 ); i < size; ++i ) std::cout << static_cast<char>( code[ i ] ) <<'#'; } void Decode( const std::string& string ){ std::string number; int d; for( int i( 0 ); i < string.size(); ++i ){ if( string[ i ] == '#' ){ std::istringstream( number ) >> d; std::cout << static_cast<char>( d ); number.clear(); }else number += string[ i ]; } } int main(){ //int arr[ 3 ] = { 97, 98, 99 }; //Decode( arr, 3 ); std::string string( "97#98#99#" ); Decode( string ); return 0; } 

    To output, you submit (char)intArray[i] and all