How do I trim leading/trailing whitespace in a standard way?

后端 未结 30 1978
一个人的身影
一个人的身影 2020-11-22 02:06

Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I\'d roll my own, but I would think this is a common problem wit

30条回答
  •  不思量自难忘°
    2020-11-22 02:46

    What do you think about using StrTrim function defined in header Shlwapi.h.? It is straight forward rather defining on your own.
    Details can be found on:
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb773454(v=vs.85).aspx

    If you have
    char ausCaptain[]="GeorgeBailey ";
    StrTrim(ausCaptain," ");
    This will give ausCaptain as "GeorgeBailey" not "GeorgeBailey ".

提交回复
热议问题