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
Server Side Programming Articles
Page 1000 of 2109
Swapping two variable value without using third variable in C/C++
In C programming, swapping two variables without using a third variable can be accomplished using arithmetic operations. This technique saves memory and demonstrates clever use of mathematical operations. Syntax a = a + b; b = a - b; a = a - b; Method 1: Using Addition and Subtraction This approach uses arithmetic operations to swap values without requiring additional memory − #include int main() { int a = 10, b = 20; printf("Before swapping: a ...
Read MorePHP – mb_preferred_mime_name() function
The mb_preferred_mime_name() function in PHP is used to return the MIME charset string for a character encoding. It gets a MIME (Multipurpose Internet Mail Extensions) charset string for the specific encoding. Syntax string mb_preferred_mime_name(string $encoding) Parameters mb_preferred_mime_name() accepts only one parameter − $encoding − The character encoding name to get the MIME charset string for. Return Value The function returns the MIME charset string for the given encoding, or false if no preferred MIME name exists for the encoding. Example 1: Basic Usage Let us see how ...
Read MorePHP – Parse the GET, POST, and COOKIE data using mb_parse_str()
The mb_parse_str() function in PHP is used to parse URL-encoded data (commonly from GET, POST, and COOKIE) and converts it into an array. It automatically detects the encoding and converts it to the internal encoding, making it useful for handling multibyte character strings. Syntax bool mb_parse_str(string $encoded_string, array &$result) Parameters The mb_parse_str() function accepts the following parameters − $encoded_string − The URL-encoded data string to be parsed. $result − An array that will hold the parsed key-value pairs after decoding and character conversion. Return Values The function returns true ...
Read MoreHow to print a variable name in C?
In C programming, you can print the name of a variable as a string using the stringizing operator (#) within a macro. This technique is useful for debugging and logging purposes where you want to display variable names along with their values. Syntax #define MACRO_NAME(variable) #variable The # operator converts the macro parameter into a string literal. Example Here's how to create a macro that prints variable names − #include #define VariableName(name) #name int main() { int age = 25; char ...
Read MorePHP – Get or set the HTTP output character encoding with mb_http_output()
The mb_http_output() function in PHP is used to get or set the HTTP output character encoding. An output, after this function is called, will be converted from the set internal encoding to the specified encoding. Syntax string|bool mb_http_output(string $encoding = null) Parameters mb_http_output() accepts only a single parameter − $encoding − It is used to set the HTTP output character encoding to the encoding. If the encoding is omitted, then mb_http_output() will return the current HTTP output character encoding. ...
Read MoreC function to Swap strings
In C programming, swapping strings involves exchanging the contents of two string variables. This can be achieved through character-by-character swapping or by swapping string pointers. Syntax // Character-by-character swapping void swapStrings(char str1[], char str2[]); // Pointer swapping void swapPointers(char **str1, char **str2); Method 1: Character-by-Character Swapping This method swaps each character of the strings individually − #include #include int main() { char st1[] = "My 1st string"; char st2[] = "My 2nd string"; char swap; ...
Read MorePHP – Detect HTTP input character encoding with mb_http_input()
The mb_http_input() function in PHP is used to detect the HTTP input character encoding from various sources like GET, POST, COOKIE data, and strings. This function is particularly useful when working with different character encodings in web applications and is supported in PHP 5.4 or higher. Syntax array|string mb_http_input(string $type = null) Parameters mb_http_input() accepts a single optional parameter − $type − Specifies the input type to check for character encoding: G − GET variables P − POST variables C − COOKIE variables S − String variables L − List of ...
Read MoreReturn values of printf() and scanf() in C
The printf() and scanf() functions are required for output and input respectively in C. Both of these functions are library functions and are defined in the stdio.h header file. Understanding their return values is crucial for error handling and program flow control. Syntax int printf(const char *format, ...); int scanf(const char *format, ...); The printf() Function Return Value The printf() function returns the number of characters that are printed successfully. If there is an error during output, it returns a negative value. Example #include int main() { ...
Read MorePHP – Get the internal settings of mbstring with mb_get_info()
The mb_get_info() function in PHP is used to get the internal settings of mbstring extension. This function is supported in PHP 5.4 or higher version and is essential for debugging and understanding current multibyte string configurations. Syntax array|string|int mb_get_info(string $type = "all") Parameters It accepts only a single parameter to get the multibyte information. $type − If the type parameter is not specified or it is specified as "all", then it will return all available mbstring settings. If a specific type is provided, it returns only that setting value. Available type values ...
Read MoreReturn type of getchar(), fgetc() and getc() in C
In C programming, the character input functions getchar(), fgetc(), and getc() all return an int value, not a char. This is crucial because they need to return both valid character values (0-255) and the special value EOF (-1) to indicate end-of-file or error conditions. Syntax int getchar(void); int fgetc(FILE *stream); int getc(FILE *stream); Why int Return Type? All three functions return int instead of char because − EOF handling: EOF is typically -1, which cannot fit in an unsigned char range (0-255) Error detection: Distinguishes between actual character values and error conditions ...
Read More