두 문자열을 연결하는 프로그램을 만드는 세 가지 방법

816 단어
1. 문자수 그룹과 자신이 쓴 함수로 실현
strcat 함수 기능이 있는 함수를 스스로 쓰다
구현 코드는 다음과 같습니다.
#include
using namespace std;
int main(){
	char a[100],b[50];
	void Strcat(char a[],char b[]);
	cout<>a;
	cout<>b;
	Strcat(a,b);
	cout<

2. 표준 라이브러리의strcat 함수로
strlen () 함수를 사용하여 수조의 크기를 구하고,strcat () 함수는 문자열을 연결하는 데 사용합니다
구현 코드는 다음과 같습니다.
#include
#include
using namespace std;
int main(){
	char a[100],b[50];
	cout<>a;
	cout<>b;
	cout<

3.string 방법으로 문자열 변수 정의
#include
#include
using namespace std;
int main(){
	string a,b;
	cout<>a;
	cout<>b;
	cout<

전재 대상:https://www.cnblogs.com/zhezh/p/3773430.html

좋은 웹페이지 즐겨찾기