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
  • 510,854
  • 105
  • 1,084
  • 1,005
balaji
  • 1,075
  • 3
  • 12
  • 26

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
  • 353,942
  • 115
  • 666
  • 851
2
s.substr(0,s.find_first_of(" "));
maxim1000
  • 6,297
  • 1
  • 23
  • 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