当前位置:网站首页>[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
边栏推荐
- Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
- msf生成payload大全
- Function: calculates the number of uppercase letters in a string
- Wu Enda's latest interview! Data centric reasons
- The difference between layer 3 switch and router
- 《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
- How to test whether an object is a proxy- How to test if an object is a Proxy?
- Résumé des points de connaissance et des réponses aux exercices après la classe du chapitre 7 de Jia junping dans la huitième édition des statistiques
- 《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
- 数字电路基础(三)编码器和译码器
猜你喜欢

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

Web vulnerability - File Inclusion Vulnerability of file operation

Network layer - simple ARP disconnection

High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters

Record an API interface 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)

SystemVerilog discusses loop loop structure and built-in loop variable I

Intranet information collection of Intranet penetration (2)

循环队列(C语言)

Data mining - a discussion on sample imbalance in classification problems
随机推荐
Intel oneapi - opening a new era of heterogeneity
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Database monitoring SQL execution
Hcip -- MPLS experiment
5 minutes to master machine learning iris logical regression classification
XSS unexpected event
Uibutton status exploration and customization
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
Build domain environment (win)
Markdown font color editing teaching
Load balancing ribbon of microservices
Realize applet payment function with applet cloud development (including source code)
关于超星脚本出现乱码问题
Binary search tree concept
Intranet information collection of Intranet penetration (4)
MySQL interview questions (4)
Attack and defense world misc practice area (GIF lift table ext3)
SystemVerilog discusses loop loop structure and built-in loop variable I