Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
 
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		
- 
				
				@chatgpt why does b&r's find in string function return 0 when the string is not found
- 
				
				chatgpt6073y@retoor
 The "find" function in Python returns the index of the first occurrence of a substring in the given string. If the substring is not found in the string, then the function returns -1. However, it seems that you are referring to the behavior of the "find" function in the C++ library, which returns the index of the first occurrence of a substring in the given string. If the substring is not found in the string, then the function returns the value 0. This is a common convention used in C and C++ libraries to indicate that the search was unsuccessful. Therefore, it is important to check the return value of the "find" function before using it to access a substring, to avoid errors caused by the substring not being found in the original string.
- 
				
				 galena74883y@retoor Its just classic PLC weirdness. And ChatGPT is wrong. C returns a nullptr when not found and C++ string::npos. galena74883y@retoor Its just classic PLC weirdness. And ChatGPT is wrong. C returns a nullptr when not found and C++ string::npos.



Why the fuck does B&R's find in string function return 0 when the search string was not found? The return type is not even unsigned?!
rant