Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 1017 of 2547
strcspn() in C
The strcspn() function in C counts the number of characters in the initial segment of a string that do not match any character from a second string. It is declared in the string.h header file and returns the length of the initial segment of the first string before the first occurrence of any character from the second string. Syntax size_t strcspn(const char *string1, const char *string2); Parameters: string1 − The string to be scanned string2 − The string containing characters to search for in string1 Return Value: Returns the number of characters ...
Read MorePHP – How to decode a MIME header field using iconv_mime_decode() function?
In PHP, iconv_mime_decode() function is used to decode MIME-encoded header fields commonly found in email messages. This function handles encoded text that uses formats like Base64 or Quoted-Printable encoding within MIME headers. Syntax string iconv_mime_decode(string $string, int $mode = 0, string $encoding = null) Parameters The iconv_mime_decode() function accepts three parameters − $string − The MIME-encoded header string to decode (required). $mode − Optional parameter that controls decoding behavior. Available constants: ICONV_MIME_DECODE_STRICT − Enforces strict RFC compliance (disabled by default due to broken mail clients) ICONV_MIME_DECODE_CONTINUE_ON_ERROR − Continues processing despite grammatical ...
Read Morefgets() and gets() in C
In C, fgets() and gets() are functions used to read strings from input streams. The key difference is that fgets() is safe and checks array bounds, while gets() is unsafe and has been removed from C11 standard due to buffer overflow vulnerabilities. fgets() Function The fgets() function reads a string from a specified stream until a newline character or the specified limit is reached − Syntax char *fgets(char *string, int size, FILE *stream); Parameters: string − Pointer to character array where the string will be stored size − Maximum number of characters ...
Read MorePHP – Decode multiple MIME header fields at once using iconv_mime_decode_headers()
In PHP, iconv_mime_decode_headers() function is used to decode multiple MIME header fields at once. It is an in-built function in PHP that processes encoded headers commonly found in email messages. Syntax iconv_mime_decode_headers($str_headers, $int_mode, $str_encoding) Parameters The iconv_mime_decode_headers() function accepts three different parameters − $headers, $mode and $encoding. $headers − The encoded headers as a string. Contains the MIME header fields to be decoded. $mode − Determines the behavior when encountering malformed MIME header fields. Can use any combination of the following bitmasks: ICONV_MIME_DECODE_STRICT − Decodes headers in full conformance with standards. ...
Read Moresize_t data type in C
The size_t data type is an unsigned integral type in C that represents the size of any object in bytes. It is returned by the sizeof operator and commonly used for array indexing, loop counters, and memory size calculations. Since it represents sizes, size_t can never be negative. Syntax size_t variable_name; const size_t variable_name = value; Where variable_name is the name of the variable of type size_t. Example: Basic Usage of size_t Here's an example demonstrating size_t for array operations and size calculations − #include #include #include ...
Read MorePHP – Retrieve internal configuration variables of iconv extension using iconv_get_encoding() function
In PHP, the iconv_get_encoding() function is used to retrieve the internal configuration variables of the iconv extension. This function allows you to check the current encoding settings that are being used by the iconv functions for character set conversion. Syntax mixed iconv_get_encoding(string $type = "all") Parameters The iconv_get_encoding() function accepts one optional parameter: $type − Specifies which encoding type to retrieve. The valid values are: all − Returns all encoding settings (default) input_encoding − Returns the input encoding setting ...
Read MorePHP – How to get the square root of an arbitrary precision number using bcsqrt() function?
In PHP, the bcsqrt() function is used to get the square root of an arbitrary precision number. It accepts the arbitrary precision number as a string and gives the square root of the number after scaling the result to the specified precision. Syntax string bcsqrt($num_string, $scale) Parameters The bcsqrt() function accepts two different parameters: $num_string and $scale. $num_string − It represents the number whose square root to be evaluated. It is a string-type parameter. $scale − It indicates the number of digits that appear ...
Read MorePHP – How to set or get the default scale parameter for all bc math functions using bcscale() function?
In PHP, the bcscale() function is used to set the default scale parameter for all bc math functions. This function sets the default number of decimal places for all following calls to bc math functions that do not explicitly specify a scale parameter. Syntax int bcscale(int $scale) Parameters The bcscale() function accepts a single mandatory parameter − $scale − An integer that specifies the number of digits after the decimal point. The default value is 0. Return Value The bcscale() function returns the old scale value as an integer. Example ...
Read Morestrdup() and strdndup() in C/C++
The functions strdup() and strndup() are used to duplicate strings in C. These functions allocate memory dynamically and create copies of existing strings. Note that these are POSIX functions, not part of the C standard library. Note: To use strdup() and strndup(), you may need to compile with -D_GNU_SOURCE flag or ensure your system supports POSIX extensions. strdup() Function The strdup() function duplicates an entire string by allocating memory and copying the string content. Syntax char *strdup(const char *string); Parameters string − Pointer to the null-terminated string to ...
Read MorePHP – bcpowmod() function
In PHP, bcpowmod() function is used to raise an arbitrary precision base number to another exponent number, reduced by a specified modulus. The bcpowmod() function accepts three arbitrary precision numbers as strings and returns the base number raised to the exponent modulo number after scaling the result to the specified precision. Syntax string bcpowmod(string $base, string $exponent, string $modulus, int $scale = 0) Parameters The bcpowmod() function accepts four different parameters − $base, $exponent, $modulus and $scale. $base − It represents the base number. It is a string type parameter. $exponent − ...
Read More