Server Side Programming Articles

Page 999 of 2109

When to use references vs. pointers in C/C++

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 610 Views

In C programming, we work with pointers to access memory addresses and manipulate data indirectly. C does not have reference variables like C++, but understanding the difference helps when transitioning between languages. Syntax // Pointer declaration and usage datatype *pointer_name; pointer_name = &variable_name; Pointers in C Pointers are variables that store memory addresses of other variables. They provide indirect access to data and enable dynamic memory allocation. Example: Basic Pointer Usage #include int main() { int a = 8; int *ptr; ...

Read More

PHP – mb_strcut() function

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 532 Views

The mb_strcut() function in PHP is used to extract a substring from a string based on byte positions rather than character positions. This is particularly useful when working with multi-byte character encodings like UTF-8, where a single character might use multiple bytes. Syntax string mb_strcut( string $str, int $start, int $length = null, string $encoding = null ); Parameters The mb_strcut() function accepts the following parameters − str − The input string to be cut. start − The starting byte ...

Read More

When to use extern in C/C++

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 15-Mar-2026 12K+ Views

In C, the extern keyword is used to declare a variable or function that is defined elsewhere in the program. It tells the compiler that the variable or function exists, but its actual definition (memory allocation) is in another file or later in the same file. Syntax // Variable declaration using extern extern datatype variable_name; // Function declaration using extern (optional) extern return_type function_name(parameters); Parameters: datatype − The data type of the variable (int, char, float, etc.) variable_name − Name of the variable to be declared return_type − Return type of the ...

Read More

PHP – mb_strrichr() function

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 185 Views

The mb_strrichr() function in PHP is used to find the last occurrence of a character in a string within another string. This function is case-insensitive, unlike mb_strrchr(). This function finds the last occurrence of a needle in the given haystack string and returns that portion of the haystack. It returns false if a needle is not found in the haystack string. Syntax string mb_strrichr( $str_haystack, $str_needle, $bool_before_needle=false, $str_encoding ) Parameters mb_strrichr() accepts the following four parameters − ...

Read More

What is the correct way to use printf to print a size_t in C/C++?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 15-Mar-2026 26K+ Views

In C programming, size_t is an unsigned integer type used to represent the size of objects and is commonly returned by functions like sizeof and strlen. To correctly print size_t variables, we should use the %zu format specifier instead of %d or other format specifiers. Syntax printf("%zu", size_t_variable); The %zu format specifier consists of − z − length modifier that specifies the argument corresponds to a size_t type u − conversion specifier for unsigned decimal integer Example 1: Basic size_t Printing This ...

Read More

PHP – mb_eregi() function

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 312 Views

The mb_eregi() function in PHP performs case-insensitive regular expression matching with multibyte support. Unlike mb_ereg(), it ignores case when comparing patterns, making it useful for international text processing. Syntax int mb_eregi( string $pattern, string $string, array &$matches = null ) Parameters pattern − The regular expression pattern to match (case-insensitive) string − The input string to search within matches − Optional array to store matched substrings. If matches are found, they are stored in this array Return Value Returns the number ...

Read More

What is the difference between g++ and gcc?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

The gcc and g++ are both GNU compiler collection tools, but they serve different purposes. gcc is primarily designed for C programs, while g++ is designed for C++ programs. Understanding their differences helps choose the right compiler for your project. Syntax gcc program.c -o executable_name g++ program.cpp -o executable_name gcc (GNU C Compiler) The gcc compiler is specifically designed to compile C programs. It treats files with .c extension as C source code and links against the standard C library by default. Example: Using gcc for C Program #include ...

Read More

PHP – mb_strrpos() function

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 386 Views

The mb_strrpos() function in PHP is used to find the position of the last occurrence of a string in another string. This function performs the multibyte safe strrpos() operation based on the number of characters and is particularly useful when working with multibyte character encodings like UTF-8. Syntax int mb_strrpos( string $haystack, string $needle, int $offset = 0, string $encoding = null ) Parameters mb_strrpos() accepts the following four parameters − $haystack − The string to search in. $needle − ...

Read More

Pre-increment and Post-increment concept in C/C++?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 15-Mar-2026 12K+ Views

Both pre-increment and post-increment are used to increase a variable's value by 1, but they behave differently in expressions. Pre-increment (++i) increases the value before it is used, while post-increment (i++) increases it after the current expression is evaluated. Syntax // Pre-increment ++variable_name; // Post-increment variable_name++; Key Differences: Pre-increment (++i) − Increments the value first, then uses the new value in the expression Post-increment (i++) − Uses the current value in the expression, then increments it Pre-Increment Operator (++x) The pre-increment operator increments the variable's value by ...

Read More

PHP – mb_strimwidth (multybyte strimwidth) function

Urmila Samariya
Urmila Samariya
Updated on 15-Mar-2026 818 Views

The mb_strimwidth() function in PHP is used to truncate a multibyte string to a specified width. This function is particularly useful for handling text in different character encodings while maintaining proper string length control. Syntax string mb_strimwidth($str, $start, $width, $trimmarker, $encoding) Parameters mb_strimwidth() accepts five parameters to control string truncation − $str − The input string to be truncated. $start − Starting position for truncation (0-based index). $width − Maximum width of the truncated string. Negative values count from the end. $trimmarker − String appended when truncation occurs (optional). $encoding − Character ...

Read More
Showing 9981–9990 of 21,090 articles
Advertisements