[英]Find character in string then insert character before that character
I am studying about string in C and I have this question . 我正在研究C中的字符串,我有这个问题。 I've had a look at some question in stackoverflow but I cant find the same Question,if there is pls give me the link :D
我已经看过stackoverflow中的一些问题,但我找不到相同的问题,如果有pls给我链接:D
For exp,I have a string "D://test.txt"
对于exp,我有一个字符串
"D://test.txt"
Now I want to convert it to "D://test1.txt"
现在我想将其转换为
"D://test1.txt"
I know that I have to find .
我知道我必须找到
.
in the string,then put the number befor it,but I dont know how to do it. 在字符串中,然后输入数字,但我不知道该怎么做。 Pls help me out :(
请帮助我:(
Use strchr()
(or strrchr()
) to find the dot. 使用
strchr()
或strrchr()
来查找点。 Both functions have their prototype in <string.h>
. 这两个函数的原型都在
<string.h>
。
There is no ready-made function for inserting a character in the middle of a string. 没有用于在字符串中间插入字符的现成功能。 You have to write your own.
你必须自己写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.