当前位置:网站首页>【指针】删除字符串s中的所有空格
【指针】删除字符串s中的所有空格
2022-07-06 09:24:00 【|光|】
要求
编一个函数,删除字符串s中的所有空格。(用指针实现)
代码
/* 该函数用来实现删除字符串中的所有空格 a为指向字符串数组的指针 */
char *delete_space(char *a)
{
int n = strlen(a);
int i=0,j=0,k=0;
char b[n];
for(i=0;i<n;i++)
{
if(a[i]==' ')
{
k++;
continue;
}
else
{
b[j]=a[i];
j++;
a[i]='\0';
}
}
for(j=0;j<n-k;j++)
{
a[j]=b[j];
}
return a;
}
main函数
int main()
{
char a[200];
gets(a);
delete_space(a);
puts(a);
return 0;
}
测试
测试输入
I A m A Student
输出
IAmAStudent
边栏推荐
- Captcha killer verification code identification plug-in
- XSS unexpected event
- A complete collection of papers on text recognition
- XSS (cross site scripting attack) for security interview
- 浅谈漏洞发现思路
- Record an API interface SQL injection practice
- Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
- Sword finger offer 23 - print binary tree from top to bottom
- What language should I learn from zero foundation. Suggestions
- Hcip -- MPLS experiment
猜你喜欢

Intranet information collection of Intranet penetration (4)

xray与burp联动 挖掘

Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class

Captcha killer verification code identification plug-in

“人生若只如初见”——RISC-V
![[paper reproduction] cyclegan (based on pytorch framework) {unfinished}](/img/16/43d8929d1a37c1c68e959d5854e18c.jpg)
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}

Record an API interface SQL injection practice

Network layer - simple ARP disconnection

JDBC transactions, batch processing, and connection pooling (super detailed)

线程的实现方式总结
随机推荐
SQL注入
Interpretation of iterator related "itertools" module usage
Internet Management (Information Collection)
Intranet information collection of Intranet penetration (3)
MySQL interview questions (4)
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
《統計學》第八版賈俊平第七章知識點總結及課後習題答案
XSS (cross site scripting attack) for security interview
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
图书管理系统
. Net6: develop modern 3D industrial software based on WPF (2)
Detailed explanation of network foundation routing
《统计学》第八版贾俊平第五章概率与概率分布
记一次,修改密码逻辑漏洞实战
1.支付系统
攻防世界MISC练习区(SimpleRAR、base64stego、功夫再高也怕菜刀)
攻防世界MISC练习区(gif 掀桌子 ext3 )
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
内网渗透之内网信息收集(五)
Detailed explanation of three ways of HTTP caching