本文介绍了CString函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想对字符串执行以下操作: 1)检查前四个字符是否为DATA 2)从以下字符串DATA 123 xyz中获取中间的单词。 ( 中间词是可变长度) - 提取123。 3)从以下字符串中获取最后一个单词/数字数据发送1467436267 我应该使用哪些功能来实现这一目标?我是C ++的新手,并且发现 字符串操作很棘手。 I want to do the following to strings: 1) Check if first four characters are "DATA" 2) Get the middle ''word'' from the following string "DATA 123 xyz" (themiddle word is variable length) - extract the "123". 3) Get the last word/number from the following string "DATA SEND 1467436267" What functions should I use to achieve this? I''m new to C++ and findingstring manipulation tricky.推荐答案 如果你使用CString,它为此提供了很多设施。看看 at - CString :: Left CString :: Mid CString ::正确 CString ::查找 CString :: Tokenize 问候, Hugh If you use CString it provides lots of facilities for this. Have a lookat - CString::LeftCString::MidCString::RightCString::FindCString::Tokenize Regards, Hugh CString不是标准的C ++类。查看microsoft.public。* newsgrouop for CString。 对于std :: string,请使用: std :: string :: substr(), std :: string :: find_first_of() std :: string :: find_last_of() CString is not a standard C++ class. Look in a microsoft.public.*newsgrouop for CString. For std::string, use : std::string::substr(),std::string::find_first_of()std::string::find_last_of() ....这是发布到microsoft.public.vc.language和 microsoft.public.vc.mfc我可能会补充说,我们最近想出了CString规则的 结论! :) - - Mark Randall http://zetech.swehli.com 那些认为他们知道一切的人对那些人来说是一个很大的烦恼> 我们的人 Isaac Asimov .... This is posted to microsoft.public.vc.language andmicrosoft.public.vc.mfc where, I might add, we recently came up with theconclusion that CString rules! :) --- Mark Randall http://zetech.swehli.com "Those people that think they know everything are a great annoyance to thoseof us who do"Isaac Asimov 这篇关于CString函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 20:46