Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 52 of 151

size_t data type in C

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

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 More

Difference between %d and %i format specifier in C

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

In C programming, both %d and %i are format specifiers used for integer values, but they behave differently when used with scanf() for input operations. For printf(), they work identically. Syntax printf("%d", integer_variable); // Decimal output printf("%i", integer_variable); // Integer output (same as %d for printf) scanf("%d", &integer_variable); // Reads decimal integers only scanf("%i", &integer_variable); // Reads decimal, octal, and hexadecimal Format Specifier %d The %d format specifier handles signed decimal integers. For printf(), it displays integers in decimal form. For scanf(), it only accepts decimal ...

Read More

Difference between getc(), getchar(), getch() and getche()

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

All these functions read characters from input and return an integer. They differ in their source, buffering behavior, and echo characteristics. Syntax int getc(FILE *stream); int getchar(void); int getch(void); /* Non-standard */ int getche(void); /* Non-standard */ getc() The getc() function reads a single character from a specified file stream and returns it as an integer. It waits for the Enter key and uses buffered input. Example #include int main() { char val; printf("Enter the character: ...

Read More

How to print % using printf()?

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

In C, the printf() function uses the percent symbol (%) as a format specifier. To print the actual % character as text, you need to use a double percent (%%) because a single % has special meaning in printf() and will not display anything. Syntax printf("%%"); // Prints a single % character Example 1: Basic % Printing Here's how to print the % symbol using printf() − #include int main() { printf("Single percent: %%"); printf("Percentage: 85%%"); printf("Multiple: ...

Read More

"extern" keyword in C

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

The extern keyword in C is used to declare variables and functions that are defined elsewhere, either in the same file or in other source files. It extends the visibility of variables and functions across multiple files, making them globally accessible. Syntax extern data_type variable_name; extern data_type function_name(parameters); Key Properties Scope − Global throughout the program, not bound by any function. Default value − Global variables are initialized to zero by default. Lifetime − Exists until the end of program execution. Important Points External variables can be declared multiple times but ...

Read More

Migrating PHP 5.x to PHP 7 on CentOS 7

Samual Sam
Samual Sam
Updated on 15-Mar-2026 552 Views

In this article, we will learn how to upgrade PHP 5.x to PHP 7 on CentOS 7. PHP 7, released in 2015, offers significant performance improvements over previous PHP versions. Prerequisites You need PHP 5.x already installed on CentOS 7 with mod_php enabled in Apache, plus sudo privileges or root access. Enabling the PHP 7 Repository Since PHP 7.x is not available in official CentOS repositories, we'll use the IUS Community Project Repository. Download the IUS repository setup script − # curl 'https://setup.ius.io/' -o setup-ius.sh curl 'https://setup.ius.io/' -o setup-ius.sh ...

Read More

Extracting only date from datetime field in MySQL and assigning it to PHP variable?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 800 Views

In PHP, you can extract only the date from a MySQL datetime field using the DateTime class. This is useful when you need to display or process only the date portion without time information. Syntax DateTime::createFromFormat("Y-m-d H:i:s", yourDateTimeValue)->format("yourFormatSpecifier"); Example Here's how to extract only the date from a MySQL datetime value ? 13/02/2018 Different Date Formats You can format the extracted date in various ways by changing the format specifier ? Y-m-d format: 2018-02-13 F j, Y format: February ...

Read More

How can I get enum possible values in a MySQL database using PHP?

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

You can get the enum possible values in a MySQL database using PHP by querying the INFORMATION_SCHEMA.COLUMNS table. This approach allows you to extract enum values programmatically without hardcoding them in your application. Database Setup First, let's create a sample table with an ENUM column ? CREATE TABLE EnumDemo ( Id int, Color ENUM('RED','GREEN','BLUE','BLACK','ORANGE') ); Method 1: Basic Query to Get Enum Values Use the INFORMATION_SCHEMA.COLUMNS table to retrieve the enum definition ? enum('RED','GREEN','BLUE','BLACK','ORANGE') Method 2: Extract Individual Enum Values Parse the enum string to get individual values as an array ?

Read More

Extract the Day / Month / Year from a Timestamp in PHP MySQL?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 974 Views

To extract the Day/Month/Year from a timestamp in PHP, you can use the date_parse() function. This function parses a date string and returns an associative array with detailed date and time components. Syntax print_r(date_parse("anyTimeStampValue")); Example Let's extract day, month, and year from a timestamp using date_parse() ? Array ( [year] => 2019 [month] => 2 [day] => 4 [hour] => 12 [minute] => 56 ...

Read More

IntlChar getCombiningClass() function in PHP

Samual Sam
Samual Sam
Updated on 15-Mar-2026 93 Views

The IntlChar getCombiningClass() function is used to get the combining class value of a Unicode character. The combining class determines how a character interacts with adjacent characters in text rendering and normalization. Syntax int IntlChar::getCombiningClass(mixed $codepoint) Parameters codepoint − An integer codepoint value, or a character encoded as a UTF-8 string. Return Value Returns the combining class of the character as an integer. Returns 0 for base characters and non-zero values for combining marks. Returns NULL on failure or for invalid input. Example The following ...

Read More
Showing 511–520 of 1,507 articles
« Prev 1 50 51 52 53 54 151 Next »
Advertisements