当前位置:网站首页>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.
边栏推荐
- 《统计学》第八版贾俊平第二章课后习题及答案总结
- 安全面试之XSS(跨站脚本攻击)
- SystemVerilog discusses loop loop structure and built-in loop variable I
- Function: string storage in reverse order
- Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
- 《统计学》第八版贾俊平第七章知识点总结及课后习题答案
- 《统计学》第八版贾俊平第四章总结及课后习题答案
- 线程的实现方式总结
- Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
- Matplotlib绘图快速入门
猜你喜欢
Xray and burp linkage mining
图书管理系统
Database monitoring SQL execution
Markdown font color editing teaching
SystemVerilog discusses loop loop structure and built-in loop variable I
Based on authorized access, cross host, and permission allocation under sqlserver
Circular queue (C language)
An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
《统计学》第八版贾俊平第二章课后习题及答案总结
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
随机推荐
Binary search tree concept
Record an edu, SQL injection practice
Interview Essentials: what is the mysterious framework asking?
Overview of LNMP architecture and construction of related services
《统计学》第八版贾俊平第五章概率与概率分布
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
Lintcode logo queries the two nearest saplings
SQL injection
How to earn the first pot of gold in CSDN (we are all creators)
Internet Management (Information Collection)
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
关于超星脚本出现乱码问题
Captcha killer verification code identification plug-in
《统计学》第八版贾俊平第一章课后习题及答案总结
关于交换a和b的值的四种方法
【指针】查找最大的字符串
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
函数:求方程的根
Web vulnerability - File Inclusion Vulnerability of file operation
Database monitoring SQL execution