The strstr command in programming is used to find a sub string within a string. If nothing is found the pointer is returned to the beginning of the sub string.
With strstr you can find a certain letter, number, or symbol in a string. A basic function could be to figure out if an email address is valid or not.The strstr in $domain is looking for "@" in $email and the strstr in $dot is looking for a "." in $domain. The if means if $domain and $dot equal nothing(it would show up as blank because there is no "@" in $email so the strstr in $domain returns false and that would in turn return the strstr in $dot as false also), do something. then the else is if $domain and $dot equal something besides "" do something else.The stristr function is just a Case-Insensitive version of strstr.
I use the following function in C++: unsigned int RomanToArabic( const char * pRoman, int len, const unsigned int uStandard /* = 2 */) { // Assume invalid until proven otherwise. unsigned int arabic = 0; // Ensure the string parameter is non-null. if( !pRoman ) return( arabic ); // Ensure the length parameter is positive. if( len < 1 ) return( arabic ); // Ensure the string parameter is null-terminated // within len chars. char * pR = ( char * ) pRoman; while( *pR && pR - pRoman < len - 1 ) ++pR; if( *pR ) return( arabic ); // Adjust length (exlude null-terminator). len = pR - pRoman; int buffer = len + 1; // include null-terminator in buffer. // Copy the string. char * pCopy = ( char * ) malloc( buffer ); memset( pCopy, 0, buffer ); strcpy_s( pCopy, buffer, pRoman ); // Convert the copy to lowercase. _strlwr( pCopy ); // Ensure the copy contains valid Roman numerals. if( strspn( pCopy, "ivxlcdm") != len ) { free( pCopy ); return( arabic ); } // Universal standard (applies to all Roman numerals). if( // Invalid double sequences. strstr( pCopy, "vv" ) // = x strstr( pCopy, "ll" ) // = c strstr( pCopy, "dd" ) // = m // Sequences of 5 are never permitted. strstr( pCopy, "iiiii" ) // = v strstr( pCopy, "xxxxx" ) // = l strstr( pCopy, "ccccc" ) // = d strstr( pCopy, "mmmmm")) // no alternative { free( pCopy ); return( arabic ); } // Accepted standard (includes universal standard). if( uStandard && ( // Sequences of 4 are not permitted. strstr( pCopy, "iiii" ) strstr( pCopy, "xxxx" ) strstr( pCopy, "cccc" ) strstr( pCopy, "mmmm") // Invalid subtractions. strstr( pCopy, "vx" ) strstr( pCopy, "lc" ) strstr( pCopy, "dm" ) // Two small values before a large value are not permitted. strstr( pCopy, "iiv" ) strstr( pCopy, "iix" ) strstr( pCopy, "iil" ) strstr( pCopy, "iic" ) strstr( pCopy, "iid" ) strstr( pCopy, "iim" ) strstr( pCopy, "xxl" ) strstr( pCopy, "xxc" ) strstr( pCopy, "xxd" ) strstr( pCopy, "xxm" ) strstr( pCopy, "ccd" ) strstr( pCopy, "ccm" ) )) { free( pCopy ); return( arabic ); } // Strict standard (includes accepted standard). if( uStandard > 1 && ( // i subtracts from v and x only. strstr( pCopy, "il" ) strstr( pCopy, "ic" ) strstr( pCopy, "id" ) strstr( pCopy, "im" ) // v cannot be subtracted. strstr( pCopy, "vl" ) strstr( pCopy, "vc" ) strstr( pCopy, "vd" ) strstr( pCopy, "vm" ) // x subtracts from l and c only. strstr( pCopy, "xd" ) strstr( pCopy, "xm" ) // l cannot be subtracted. strstr( pCopy, "ld" ) strstr( pCopy, "lm" ) )) { free( pCopy ); return( arabic ); } // Point to the last numeral. pR = (( char * ) pCopy ); pR += len; int value = 0; // The current value. int previous = 0; // The value to the right. // Begin with the last Roman numeral. int index = buffer; // Iterate the Roman numerals. while( index ) { // Evaluate the current digit. switch( *pR ) { case('i'): value = 1; break; case('v'): value = 5; break; case('x'): value = 10; break; case('l'): value = 50; break; case('c'): value = 100; break; case('d'): value = 500; break; case('m'): value = 1000; break; } // Subtract? if( value < previous ) { // Accepted and strict only. if( uStandard ) value *= (-1); else { // Invalid!! value = 0; arabic = 0; index = 1; } } // Update the arabic numeral. arabic += value; // Update the previous value for next iteration. previous = value; // Point to the numeral to the left. if( --index ) --pR; } free( pCopy ); return( arabic ); }
There are no commands in C-programming, you should use function sqrt from math.h
you can use strstr()
in C: strstr, declared in string.h
There is not switch called "if". We generally use "if" statement in batch programming in DOS.
The easiest way for beginners to understand how to use the "puts" command in programming is to think of it as a way to display text on the screen. Just type "puts" followed by the text you want to show, enclosed in quotation marks. This will help you see the output of your program and understand how the command works.
The term "fprintf" is a command used in the computer programming language C++. The command "fprintf" in C++ is used to print formatted data to a stream.
Java is the programming language where substr is used. Substr is a command that returns the characters in a string beginning at the specified location through the specified number of characters.
"Gettype" is a computer programming command used to return a type of variable. The command used is "gettype()" where the variable wanted is placed immediately after the gettype command and is in brackets. variables that can be delivered with the command gettype include data, number, list and text. An example of a complete command is writ gettype(NUM) for a number variable.
I go to http://www.programingtutorials.com/
If you try the command 'man sed' you see it is listed as one of the examples of what sed can do.