修剪在C字符串 [英] Trim a string in C

查看:96
本文介绍了修剪在C字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:

我.NET的 String.Trim 在C语言中使用Win32和标准C API相当于后感到(与MSVC2008编译所以我要所有的C ++的东西访问如果需要的话,但我只是想修剪的char * )。

I'm after the equivalent of .NET's String.Trim in C using the win32 and standard C api (compiling with MSVC2008 so I have access to all the C++ stuff if needed, but I am just trying to trim a char*).

由于有和strchr strtok的,以及其他字符串函数的所有方式,肯定应该有一个微调功能,或者一个可以改变用途...

Given that there is strchr, strtok, and all manner of other string functions, surely there should be a trim function, or one that can be repurposed...

感谢

推荐答案

有没有标准库函数来做到这一点,但它不是太难滚你自己。有一个<一个href=\"http://stackoverflow.com/questions/122616/painless-way-to-trim-leadingtrailing-whitespace-in-c\">existing问题SO 的上这样做这一点,得到的回答是源$ C ​​$ C。

There is no standard library function to do this, but it's not too hard to roll your own. There is an existing question on SO about doing this that was answered with source code.

这篇关于修剪在C字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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