如何从字符串指针中删除字符 [英] How to remove chars from a string pointer

查看:306
本文介绍了如何从字符串指针中删除字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




any1知道一种方法,你可以搜索字符串并从特定指针中删除字符,直到换行。例如:


这是一个测试@A测试这是


如何使它如此搜索指针(例如@)并且这样做:


这是一个测试


感谢您对高级的帮助!!!

解决方案

看看 strchr()功能。


亲切的问候,


Jos


< blockquote> @ JosAH


我知道dat函数但是,如何在使用它之后删除其余的字符是问题所在。这只会指向我,它不会删除或删除任何东西。


@imLVcrazy


如果该函数返回a非NULL指针将其值(即指向它的位置)设置为''\0'';有效地设置字符串的结尾;根本不需要删除任何内容。


亲切的问候,


Jos


Hi

Does any1 know of a method where you can search through a string and remove chars from a specific pointer until the new line. For example:

"This is a test @ A test this is"

how do make it so u search for a pointer (e.g.@) and make it this:

"This is a test"

Thanks for your help in advanced!!!

解决方案

Have a look at the strchr() function.

kind regards,

Jos


@JosAH
I know of dat function but, how do i delete the rest of the chars after using it is the problem. that will only point me to it, it wont delete or erase anything.


@imLVcrazy
If that function return a non-NULL pointer set its value (i.e. to where it points) to ''\0''; that effectively sets the end of the string; no need to erase anything at all.

kind regards,

Jos


这篇关于如何从字符串指针中删除字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆