当前位置:网站首页>[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
边栏推荐
- Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
- 函数:字符串反序存放
- ES全文索引
- Sentinel overall workflow
- Function: find the root of the equation by Newton iterative method
- Numpy Quick Start Guide
- DVWA (5th week)
- Get started with Matplotlib drawing
- Load balancing ribbon of microservices
- 指针:最大值、最小值和平均值
猜你喜欢
Record an edu, SQL injection practice
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
Network layer - simple ARP disconnection
ES全文索引
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
Internet Management (Information Collection)
数字电路基础(一)数制与码制
5分钟掌握机器学习鸢尾花逻辑回归分类
How does SQLite count the data that meets another condition under the data that has been classified once
攻防世界MISC练习区(SimpleRAR、base64stego、功夫再高也怕菜刀)
随机推荐
内网渗透之内网信息收集(二)
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
1.支付系统
JDBC read this article is enough
《统计学》第八版贾俊平第四章总结及课后习题答案
Xray and burp linkage mining
数字电路基础(四) 数据分配器、数据选择器和数值比较器
Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
Detailed explanation of network foundation
Ucos-iii learning records (11) - task management
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
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
Intel oneapi - opening a new era of heterogeneity
Uibutton status exploration and customization
Web vulnerability - File Inclusion Vulnerability of file operation
JDBC事务、批处理以及连接池(超详细)
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
Captcha killer verification code identification plug-in