Switch to full style
C++ code examples
Post a reply

find a string

Thu Nov 13, 2008 7:29 pm

Search for a string using C++
cpp code
#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
string string1( "This is a test string!");
int location;

cout << "Original string:\n" << string1
<< "\n\n(find) \"is\" was found at: " << string1.find( "is" );


return 0;
}

/*
Original string:
This is a test string!

(find) "is" was found at: 2
*/




Post a reply
  Related Posts  to : find a string
 How to find server IP, PORT using String     -  
 Find occurrences of each character in a string     -  
 Splitting a String Based on a Found String     -  
 recursive string reversal- reverse string     -  
 check if string ends with specific sub-string in php     -  
 check if string start with a specific sub-string in PHP     -  
 String token for string split     -  
 Find MAC Address     -  
 Find entity by id     -  
 cannot find symbol constructor     -  

Topic Tags

C++ Strings