标题:求这题的答案。
只看楼主
浅墨初白
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2018-3-29
结帖率:70%
已结贴  问题点数:30 回复次数:1 
求这题的答案。
题目:编写函数fun,其功能是:删除一个字符串中指定下标的字符。其中,a指向原字
      符串,删除指定字符后的字符串存放在b所指的数组中,n中存指定的下标。

例如:输入一个字符串world,然后输入3,则调用该函数后的结果为word。

注意:请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入
      你编写的若干语句。

-------------------------------------------------------*/

#include <stdio.h>
#include <string.h>

#define LEN 20

void fun (char a[], char b[], int n)
{
/**********Program**********/

 


  
/**********  End  **********/
}

void main( )
{  
        char str1[LEN], str2[LEN] ;
        int n ;
        printf("Enter the string:\n") ;
        gets(str1) ;
        printf("Enter the position of the string deleted:") ;
        scanf("%d", &n) ;
        fun(str1, str2, n) ;
        printf("The new string is: %s\n", str2) ;
}
搜索更多相关主题的帖子: 函数 fun 指定 string the 
2018-06-28 22:50
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:30 
    strncpy(b,a,n);
    strcpy(b+n,a+n+1);
2018-06-29 05:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488252-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.141593 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved