当前位置:网站首页>[pointer] delete all spaces in the string s
[pointer] delete all spaces in the string s
2022-07-06 14:35:00 【|Light|】
requirement
Make up a function , Delete string s All spaces in .( Use a pointer to achieve )
Code
/* This function is used to delete all spaces in the string a Is a pointer to a string array */
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 function
int main()
{
char a[200];
gets(a);
delete_space(a);
puts(a);
return 0;
}
test
Test input
I A m A Student
Output
IAmAStudent
边栏推荐
- Detailed explanation of network foundation routing
- AQS details
- Mathematical modeling idea of 2022 central China Cup
- Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
- Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
- 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 12 summary of knowledge points of multiple linear regression and answers to exercises after class
- {1,2,3,2,5}查重问题
- 【指针】使用插入排序法将n个数从小到大进行排列
猜你喜欢
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
数字电路基础(一)数制与码制
《统计学》第八版贾俊平第二章课后习题及答案总结
数字电路基础(五)算术运算电路
JDBC看这篇就够了
图书管理系统
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
Intel oneapi - opening a new era of heterogeneity
JDBC read this article is enough
Xray and burp linkage mining
随机推荐
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
网络基础详解
数字电路基础(三)编码器和译码器
内网渗透之内网信息收集(三)
Circular queue (C language)
Intranet information collection of Intranet penetration (5)
Captcha killer verification code identification plug-in
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
攻防世界MISC练习区(SimpleRAR、base64stego、功夫再高也怕菜刀)
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Load balancing ribbon of microservices
安全面试之XSS(跨站脚本攻击)
【指针】求解最后留下的人
Functions: Finding Roots of equations
Markdown font color editing teaching
Always of SystemVerilog usage_ comb 、always_ iff
ES全文索引
“人生若只如初见”——RISC-V
Only 40% of the articles are original? Here comes the modification method