当前位置:网站首页>[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
边栏推荐
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- Sentinel overall workflow
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- 《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
- captcha-killer验证码识别插件
- JDBC read this article is enough
- Detailed explanation of network foundation
- MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
- Network technology related topics
- 数字电路基础(三)编码器和译码器
猜你喜欢
Uibutton status exploration and customization
Network technology related topics
《统计学》第八版贾俊平第四章总结及课后习题答案
Realize applet payment function with applet cloud development (including source code)
How does SQLite count the data that meets another condition under the data that has been classified once
Interview Essentials: what is the mysterious framework asking?
《英特尔 oneAPI—打开异构新纪元》
On the idea of vulnerability discovery
网络基础详解
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
随机推荐
Xray and Burp linked Mining
Numpy Quick Start Guide
flask实现强制登陆
How does SQLite count the data that meets another condition under the data that has been classified once
Overview of LNMP architecture and construction of related services
JDBC看这篇就够了
函数:用牛顿迭代法求方程的根
指针:最大值、最小值和平均值
Uibutton status exploration and customization
JDBC read this article is enough
. Net6: develop modern 3D industrial software based on WPF (2)
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
Record an API interface SQL injection practice
How to test whether an object is a proxy- How to test if an object is a Proxy?
【指针】求二维数组中最大元素的值
“人生若只如初见”——RISC-V
Function: find the root of the equation by Newton iterative method
《统计学》第八版贾俊平第一章课后习题及答案总结
【指针】统计一字符串在另一个字符串中出现的次数