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 1002 of 2109
What are Wild Pointers in C/C++?
In C, a wild pointer is a pointer that has not been initialized to a valid memory address. When a pointer is declared but not assigned a value, it contains garbage data and points to an unknown memory location, making it unpredictable and dangerous to use. Syntax data_type *pointer_name; // Uninitialized pointer (wild pointer) Example: Wild Pointer Behavior Here's an example demonstrating a wild pointer that attempts to access uninitialized memory − #include int main() { int *ptr; // Wild pointer - ...
Read MorePHP – How to get the substitution character using mb_substitute_character()?
In PHP, we can use the function mb_substitute_character() to get or set the substitution character. This function specifies the substitution character when the input character encoding is not valid or the character code does not exist in the output character encoding. Note: The invalid characters may be substituted with no output, string, or int value (Unicode character code value). Syntax string mb_substitute_character($char) Parameters This function accepts only one parameter, $char. $char − It specifies the Unicode value as an integer or the strings given below: "none" − It will return ...
Read MoreHow will you print numbers from 1 to 100 without using loop in C?
You can print numbers from 1 to 100 without using traditional loops by employing alternative control structures like recursive functions and goto statements. These methods achieve the same repetitive behavior through different mechanisms. Method 1: Using Recursion Recursion allows a function to call itself repeatedly until a base condition is met. We can use this property to print numbers sequentially without explicit loops − #include void printNumbers(int n) { if (n > 100) return; printf("%d ", n); ...
Read MorePHP – Make a lower case string using mb_strtolower()
In PHP, we can use the function mb_strtolower() to change a given string into lower case. It returns strings with all alphabetic characters converted to lowercase characters, with proper support for multibyte character encodings. Syntax string mb_strtolower(string $string, ?string $encoding = null) Parameters mb_strtolower() accepts two parameters: $string and $encoding. $string − The string being lowercased, returns strings with all alphabetic characters converted to lowercase characters. $encoding − This parameter is the character encoding. If it is absent or null, then the internal character encoding value will be used. Return ...
Read MorePHP – Make an upper case string using mb_strtoupper()
In PHP, mb_strtoupper() is a multibyte string function that converts all alphabetic characters in a string to uppercase. Unlike the regular strtoupper() function, it properly handles multibyte characters and various character encodings. Syntax string mb_strtoupper(string $string, ?string $encoding = null) Parameters mb_strtoupper() accepts two parameters: $string and $encoding. $string− The string being converted to uppercase. $encoding− The character encoding. If omitted or null, the internal character encoding value will be used. Return Value Returns a string with all alphabetic characters converted to uppercase. Example Here's how to ...
Read MoreHow to clear console in C?
In C, clearing the console or output screen can be achieved using several methods. While clrscr() from conio.h was commonly used in older compilers, modern standard C uses system() calls for cross-platform compatibility. Note: The examples below use system() calls which work in most environments. For online compilers, console clearing may not be visible as output is captured after program execution. Syntax The following are standard methods to clear the console in C − #include system("cls"); /* Windows */ Or, #include system("clear"); /* ...
Read MorePHP – How to get the selected part of a string using mb_substr()?
In PHP, mb_substr() is used to return the selected part of a given string. The multibyte safe substr() works based on the number of characters. It counts the position from the starting of the string. It will return 0 for the first character position and 1 for the second position character, and so on. Syntax string mb_substr(str $string, int $start, int $length, str $encoding) Parameters This PHP function accepts four parameters: $string, $start, $length and $encoding. $string − This parameter is used to extract the substring from the ...
Read Moreatexit() function in C/C++
The atexit() function in C is used to register functions that will be called automatically when the program terminates normally. These registered functions are executed in reverse order (LIFO - Last In, First Out) after the main function completes but before the program ends. This function is declared in the header file. Syntax int atexit(void (*function_name)(void)) Parameters: function_name − A pointer to the function that will be called at program termination. The function must take no parameters and return void. Return Value: Returns 0 on success, or a non-zero value if ...
Read MorePHP – Case folding in a string using mb_convert_case()
The mb_convert_case() function is an inbuilt PHP function used to perform case folding on a given string. It supports multibyte character encodings and offers various conversion modes for different case transformations. Syntax string mb_convert_case(string $string, int $mode, ?string $encoding = null) Parameters The mb_convert_case() function accepts three parameters ? $string − The input string to be converted. $mode − The conversion mode. Available constants include: MB_CASE_UPPER − Convert to uppercase MB_CASE_LOWER − Convert to lowercase MB_CASE_TITLE − Convert to title case MB_CASE_FOLD − Case folding (PHP 7.3+) MB_CASE_UPPER_SIMPLE − Simple uppercase ...
Read MoreDifference between strlen() and sizeof() for string in C
In C programming, strlen() and sizeof() are commonly used to work with strings, but they serve different purposes and return different values. Understanding their differences is crucial for effective string manipulation. strlen() Function The strlen() function is declared in string.h header file and calculates the actual length of a string by counting characters until it encounters the null terminator '\0'. Syntax size_t strlen(const char *string); string − The string whose length is to be calculated. Example #include #include int main() { char s1[10] ...
Read More