当前位置:网站首页>[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
边栏推荐
- Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
- How does SQLite count the data that meets another condition under the data that has been classified once
- Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
- Get started with Matplotlib drawing
- 指針:最大值、最小值和平均值
- An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
- 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
- 指针:最大值、最小值和平均值
- Fundamentals of digital circuit (V) arithmetic operation circuit
- Binary search tree concept
猜你喜欢

Internet Management (Information Collection)

Hackmyvm target series (2) -warrior

Intranet information collection of Intranet penetration (5)

Interview Essentials: what is the mysterious framework asking?

Web vulnerability - File Inclusion Vulnerability of file operation

Record an API interface SQL injection practice

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

Constants, variables, and operators of SystemVerilog usage

Circular queue (C language)

Xray and Burp linked Mining
随机推荐
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
Xray and Burp linked Mining
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
JVM memory model concept
Only 40% of the articles are original? Here comes the modification method
Mathematical modeling idea of 2022 central China Cup
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
Build domain environment (win)
Sentinel overall workflow
Sword finger offer 23 - print binary tree from top to bottom
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
【指针】删除字符串s中的所有空格
Detailed explanation of network foundation
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
XSS (cross site scripting attack) for security interview
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
我的第一篇博客
JDBC transactions, batch processing, and connection pooling (super detailed)
JDBC read this article is enough