0

I have following string:

"hw_core_detectionhook::Iocard const*"

I have to get only first part, i.e all text present before space, i.e I need the "hw_core_detectionhook::Iocard" part only.

kennytm
  • 491,404
  • 99
  • 1,053
  • 989
balaji
  • 913
  • 2
  • 11
  • 24

2 Answers2

3
std::stringstream ss;

ss << "hw_core_detectionhook::Iocard const*";

std::string s;

ss >> s;

std::cout << s;

Output:

hw_core_detectionhook::Iocard

See the complete demo online : http://www.ideone.com/w9l1C

Nawaz
  • 341,464
  • 111
  • 648
  • 831
2
s.substr(0,s.find_first_of(" "));
maxim1000
  • 6,052
  • 1
  • 21
  • 19
  • thanks but above expression wil provide me second part i.e const* – balaji Apr 19 '11 at 13:08
  • I've tried and it seems to provide the first part: http://www.ideone.com/Q84m9. If s.find_first_of would be the first argument - then it would provide " const*". – maxim1000 Apr 19 '11 at 13:19