Home > Software engineering >  how to convert a numeric into a char number?
how to convert a numeric into a char number?

Time:04-20

The problem is the next, generate a new string, 1. In the firt place : the firts letter of the name 2. In the second place : the third letter of the name 3. In the thitd place : The last letter of the name 4. In the fourth place : the lenght of the character int main(){

char cad1[10]={};
char cad2[4]={};
int  n ; 

cout<<"Ingresa un nombre de 4 o mas letras : " ;
cin.getline(cad1,10,'\n') ;

n =  strlen(cad1) ;
    
cad2[0] = cad1[0] ;
cad2[1] = cad1[2] ;
cad2[2] = cad1[n-1] ;
cad2[3] ??

cout<<cad2;
cout<<endl ;
system("PAUSE") ; return 0 ; 

}

CodePudding user response:

Welcome to Stack Overflow! If I understood your question correctly, you need to save the typed name length on the last char. If that's the case, just do:

cad2[3] = n   '0';
  • Related