Difference between revisions of "CPP/Strings/Find"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with '==Find.cpp== <source lang="cpp"> #include <iostream> #include <string> #include <algorithm> int main(int argc, char *argv[]) { std::string hello = "hello"; int pos = hello.…') |
(No difference)
|
Latest revision as of 21:05, 8 December 2010
Find.cpp
#include <iostream> #include <string> #include <algorithm> int main(int argc, char *argv[]) { std::string hello = "hello"; int pos = hello.find("he"); // should return 0 std::cout << "pos of 'he' " << pos << std::endl; pos = hello.find("lo"); // should return 3 std::cout << "pos of 'lo' " << pos << std::endl; pos = hello.find("test"); // should return -1 std::cout << "pos of 'test' " << pos << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(Find) ADD_EXECUTABLE(Find Find.cpp )