c++中定义了string类字符数组,如何输出string里单个字符(比如第二个字符)。
展开全部
d
Press any key to continue
#include <iostream>
#include <string>
using namespace std;
main()
{
string aa="123asdf";
cout<<aa[5]<<endl;
}
Press any key to continue
#include <iostream>
#include <string>
using namespace std;
main()
{
string aa="123asdf";
cout<<aa[5]<<endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/* STRCPY.C: This program uses strcpy
* and strcat to build a phrase.
*/
#include <string.h>
#include <stdio.h>
void main( void )
{
char string[80];
strcpy( string, "Hello world from " );
strcat( string, "strcpy " );
strcat( string, "and " );
strcat( string, "strcat!" );
printf( "String = %s\n", string );
}
Output
String = Hello world from strcpy and strcat!
* and strcat to build a phrase.
*/
#include <string.h>
#include <stdio.h>
void main( void )
{
char string[80];
strcpy( string, "Hello world from " );
strcat( string, "strcpy " );
strcat( string, "and " );
strcat( string, "strcat!" );
printf( "String = %s\n", string );
}
Output
String = Hello world from strcpy and strcat!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询