当前位置:网站首页>【指针】删除字符串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
边栏推荐
- 线程的实现方式总结
- Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
- Wu Enda's latest interview! Data centric reasons
- Only 40% of the articles are original? Here comes the modification method
- Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
- Hackmyvm target series (4) -vulny
- What language should I learn from zero foundation. Suggestions
- 外网打点(信息收集)
- 我的第一篇博客
- Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
猜你喜欢

Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class

How to earn the first pot of gold in CSDN (we are all creators)

《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案

Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary

Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution

内网渗透之内网信息收集(五)

Database monitoring SQL execution

WEB漏洞-文件操作之文件包含漏洞

Only 40% of the articles are original? Here comes the modification method

外网打点(信息收集)
随机推荐
List and data frame of R language experiment III
Web vulnerability - File Inclusion Vulnerability of file operation
Data mining - a discussion on sample imbalance in classification problems
“人生若只如初见”——RISC-V
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Hackmyvm target series (2) -warrior
Proceedingjoinpoint API use
An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
外网打点(信息收集)
JDBC看这篇就够了
[err] 1055 - expression 1 of order by clause is not in group by clause MySQL
2022华中杯数学建模思路
Markdown font color editing teaching
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
《统计学》第八版贾俊平第四章总结及课后习题答案
xray與burp聯動 挖掘
7-7 7003 combination lock (PTA program design)
Internet Management (Information Collection)
This article explains in detail how mockmvc is used in practical work