亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

以下代碼中,求問關于目的實現字符串連接,函數如何實現呢?

以下代碼中,求問關于目的實現字符串連接,函數如何實現呢?

LEATH 2022-02-24 23:15:59
int count = 3;int len=4;char tmp[32];char *p; p =tmp; str_cat(str,count,len,p);目的實現字符串連接,函數如何實現呢?
查看完整描述

2 回答

?
一只萌萌小番薯

TA貢獻1795條經驗 獲得超7個贊

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char po[32];
char pt[16];
char *p=po;
char *pti=pt;
void connect(char *p,char *ptw);
int main(void)
{
printf("輸入第一個字符串");
scanf("%s", po);
printf("輸入第二個字符串");
scanf("%s", pt);
connect(po,pt);
printf("連接后的字符串為:%s", po);
return 0;
}
void connect(char *p,char *ptw)
{
strcat(p,ptw);
}



查看完整回答
反對 回復 2022-02-27
?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

#include <stdio.h>
void str_cat(char **p,int count,int len,char *strout)
{
for(int i=0;i<count ;i++)
{
for(int j=0;j<len-1;j++)
{
*strout++ =*p[i]+j;
}
}
*strout='\0';

}

void main()
{
char *str[]={"abc","def","ghi"};
int count = 3;
int len=4;
char tmp[32];
char *p;
p =tmp;
str_cat(str,count,len,p);
printf("%s\n",p);
}



查看完整回答
反對 回復 2022-02-27
  • 2 回答
  • 0 關注
  • 214 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號