当前位置:网站首页>以下程序实现从字符串str中删除第i个字符开始的连续n个字
以下程序实现从字符串str中删除第i个字符开始的连续n个字
2022-04-23 06:38:00 【laocooon】
#include <stdio.h>
#include <string.h>//string 原来是stdlib
void main()
{ char str[81];
int i,n;
printf("请输入字符串str的值:\n");
scanf("%s",str);
printf("你输入的字符串str是:%s\n",str);
printf("请输入删除位置i和待删字符个数n的值:\n");
scanf("%d%d",&i,&n);
while (i+n-1>strlen(str))
{ printf("删除位置i和待删字符个数n的值错!请重新输入i和n的值\n");
scanf("%d%d",&i,&n);
}
while(str[i+n-1])//str[i+n]
{ str[i-1]=str[i+n-1];
i++;
}
str[i-1]='\0';//str[i]='\0';
printf("删除后的字符串str是:%s\n",str);
}
版权声明
本文为[laocooon]所创,转载请带上原文链接,感谢
https://laocooon.blog.csdn.net/article/details/124356666
边栏推荐
- Internal network security attack and defense: a practical guide to penetration testing (8): Authority maintenance analysis and defense
- About unity to obtain links related to the transformation of real geographic maps into 3D
- Buuctf misc brush questions
- 《内网安全攻防:渗透测试实战指南》读书笔记(四):权限提升分析及防御
- 国基北盛-openstack-容器云-环境搭建
- Ribbon启动流程
- Reptile learning notes, learning reptile, read this article is enough
- MYSQL——第一章节(数据类型2)
- MySQL -- the secret of lock -- how to lock data
- C 输出一种二维数组,特点如下。
猜你喜欢
Cloud computing skills competition -- the first part of openstack private cloud environment
Simplify exporting to SVG data files and all images in SVG folder
CTF攻防世界刷题51-
Go语学习笔记 - 异常处理 | 从零开始Go语言
Chapter IV intangible assets
Sto with billing cross company inventory dump return
Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets
Redis -- why is the string length of string emstr the upper limit of 44 bytes?
About USB flash drive data prompt raw, need to format, data recovery notes
vivo,硬件安全的爱与雷霆
随机推荐
Internal network security attack and defense: a practical guide to penetration testing (IV): Authority improvement analysis and defense
Talk about the essence of interface idempotent and consumption idempotent
利用sqlmap注入获取网址管理员账号密码
BUUCTF [极客大挑战 2019]EasySQL1
Intranet penetration series: icmptunnel of Intranet tunnel (by master dhavalkapil)
String self generated code within a given range
SAP GUI安全性
Intranet security attack and defense: a practical guide to penetration testing (6): domain controller security
Feign源码分析
Chapter IV intangible assets
读书笔记
Houdini > variable building roads, learning process notes
About unity to obtain links related to the transformation of real geographic maps into 3D
访问数据库的时候出现错误 Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.详解
Ctf-misc learning from start to give up
Search and replacement of C text file (WinForm)
随笔(不定时更新)
Houdini > rigid body, rigid body breaking RBD
Attack and defense world misc questions 1-50
Research on system and software security (4)