hey guys, could someone explain why you include string::size_type or string::npos? What do these do?
It's a type. A datatype. Like int or long or size_t or unsigned char.
You know how in C, size_t is an unsigned integer large enough to represent any array size possible? The C++ std::string class provides string::size_type as an integer datatype large enough to represent any possible string size.
The 'find' member function returns the location of the first occurrence of a substring or character in a string. This return value is an integer (whose type is string::size_type). If the substring or character is not found, it needs some value to return that signals this fact. A library designer could have said, "okay, let's return -1 when the substring's not found." But instead, they return some integer value hardcoded as string::npos. It's probably -1. Code that uses string::npos is more readable than code that uses -1. (Since you can't assume that string::npos == -1, you have to use string::npos anyway.)
Are you able to help answer this sponsored question?
Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.
I made a prime number finder, it finds the nearest prime that is above and below any integer (Does not work that well with giant numbers.)
Made this in cpp.sh
Why would I need the x=y+1-1;?
x=y; just doesnt seem to work
Why is this?
And I know my coding ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others
there are five tables (personTb, addressTb,churchTb) each holds data pertinent to an individual; (personAddress,personChurch) each hold the primary key for the person table and corresponding table IE personAddress holds primary key for addressTb.
both snippets work, my question is; Is my join correctly formatted?
select concat(personTb.p_fName,' ',personTb.p_mName,'. ',personTb.p_lName) ...