当前位置:网站首页>Pointer -- eliminate all numbers in the string
Pointer -- eliminate all numbers in the string
2022-07-06 14:36:00 【|Light|】
requirement
Make up a function , Eliminate all numbers in the string .( Use a pointer to achieve )
Code
#include<stdio.h>
/* * This function is used to delete all numbers in the string *a Is a pointer to a string array */
char *delete_digit(char *a)
{
int l = strlen(a);
char b[l];
int i,j=0,k;
for(i=0;i<l;i++)
{
if(a[i]>='0'&&a[i]<='9')
continue;
else
{
b[j] = a[i];
j++;
}
}
for(i=0;i<l;i++)
{
a[i] = '\0';
}
for(i=0;i<l-2;i++)
{
if(b[i]=='.')
{
if(b[i+2]>='a'&&b[i+2]<='z')
continue;
else if(b[i+2]>='A'&&b[i+2]<='Z')
continue;
else
b[i+1]='\0';
}
}
strcpy(a,b);
return a;
}
main function
int main()
{
char a[200];
gets(a);
delete_digit(a);
puts(a);
return 0;
}
test
Test input
123Try234 you53r b5234est wh2435en y25ou2 are 5234young. 45324Never524 regret523.
Output
Try your best when you are young. Never regret.
边栏推荐
- Function: calculates the number of uppercase letters in a string
- 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
- JVM memory model concept
- 数字电路基础(一)数制与码制
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
- JDBC transactions, batch processing, and connection pooling (super detailed)
- Applet Web Capture -fiddler
- 关于超星脚本出现乱码问题
- Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
- Realize applet payment function with applet cloud development (including source code)
猜你喜欢

Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class

Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)

《统计学》第八版贾俊平第三章课后习题及答案总结

Matplotlib绘图快速入门

数字电路基础(一)数制与码制

Network layer - simple ARP disconnection

Hcip -- MPLS experiment

5分钟掌握机器学习鸢尾花逻辑回归分类

Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?

《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
随机推荐
The most popular colloquial system explains the base of numbers
Mathematical modeling idea of 2022 central China Cup
《统计学》第八版贾俊平第三章课后习题及答案总结
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
“人生若只如初见”——RISC-V
【指针】使用插入排序法将n个数从小到大进行排列
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
MySQL learning notes (stage 1)
指针--剔除字符串中的所有数字
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Wu Enda's latest interview! Data centric reasons
函数:字符串反序存放
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
Chain team implementation (C language)
Sentinel overall workflow
函数:求方程的根
C language file operation
JDBC read this article is enough