C++ - std::string::find (C++11)

1. find() 함수

주어진 문자열 순서와 동일한 첫 번째 부분 문자열을 찾는 함수
Finds the first substring equal to the given character sequence.

2. find() return value

찾은 부분 문자열의 첫 문자 위치 또는 해당 부분 문자열이없는 경우 npos를 return
Position of the first character of the found substring or npos if no such substring is found.

std::string str = "Hello String_World!";

std::string::size_type found;
found = str.find("S"); 
printf("%d\n", found); //6
found = str.find("World"); 
printf("%d\n", found); //13


std::string::size_type not_found;
not_found = str.find("bye");
if(not_found == std::string::npos)
{
	printf("not found\n"); //not found
}

Output:
6
13
not found

RPC Message procedure

Remote Procedure Call - Stateful Continue reading

PubSub architecture

Published on August 10, 2023

RESTful architecture

Published on August 09, 2023