如何将数字转换为字符号码?
问题是下一个,生成一个新字符串, 1。在firt的地方:名称的firt信 2。第二名:名称的第三个字母 3。在thitd的地方:名字的最后一个字母 4。第四位:角色的lenght 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 ;
}
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 ;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
欢迎来到堆栈溢出!如果我正确理解了您的问题,则需要将键入的名称长度保存在最后一个字符上。如果是这样,那就做:
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: