The C strspn() function used in C++ program example as the C++ wrapper
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional library: none/default
Additional project setting: Set project to be compiled as C++
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)
Other info: none
To do: Using the strspn() C function to returns the index of the first character in a string that does not belong to a set of characters.
To show: How to use the C strspn() function in C++ program as the C++ wrapper
// the strspn() C function as C++ wrapper example
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
char *string1 = "The initial value is 3.14159";
char *string2 = "aehilsTuv";
cout<<" Using strspn() function"<<endl;
cout<<" ------------------------------"<<endl;
cout<<"string1 = "<<string1<<endl;
cout<<"string2 = "<<string2<<endl;
cout<<endl<<"The length of the initial segment of string1"<<endl;
cout<<"containing only characters from string2 is = "<<strspn(string1, string2)<<endl;
return 0;
}
Output example:
Using strspn() function
------------------------------
string1 = The initial value is 3.14159
string2 = aehilsTuv
The length of the initial segment of string1
containing only characters from string2 is = 3
Press any key to continue . . .