George John

George John

789 Articles Published

Articles by George John

Page 26 of 79

How to pass a 2D array as a parameter in C?

George John
George John
Updated on 15-Mar-2026 1K+ Views

In C programming, a 2D array can be passed as a parameter to a function in several ways. The method depends on whether the array dimensions are known at compile time or need to be determined at runtime. Syntax // Method 1: Fixed dimensions (known at compile time) void function_name(int arr[ROWS][COLS]); // Method 2: Variable dimensions (C99 and later) void function_name(int rows, int cols, int arr[rows][cols]); // Method 3: Using pointer to array void function_name(int (*arr)[COLS]); Method 1: Using Fixed Dimensions When array dimensions are known at compile time, you can specify ...

Read More

When do function-level static variables get initialized in C/C++?

George John
George John
Updated on 15-Mar-2026 982 Views

Static variables can be defined using the static keyword. They are variables that remain in memory while the program is running, meaning their lifetime is the entire program execution. This is different from automatic variables, which remain in memory only when their function is running and are destroyed when the function exits. Function-level static variables are initialized only once − the first time the function is called. The memory for them is allocated at program load time, but the initialization occurs during the first function execution. Syntax static data_type variable_name = initial_value; Example: Static ...

Read More

How do I find the length of an array in C/C++?

George John
George John
Updated on 15-Mar-2026 22K+ Views

To find the length of an array in C, we can use various approaches that are essential for array manipulation. Finding the length of an array is a fundamental task used in looping through arrays, sorting, searching, and memory management operations. In this article, we will explore different methods to determine the size of an array in C programming. Syntax // Method 1: Using sizeof operator int length = sizeof(array) / sizeof(array[0]); // Method 2: Using pointer arithmetic int length = *(&array + 1) - array; Method 1: Using sizeof() Operator The ...

Read More

imagecolortransparent() function in PHP

George John
George John
Updated on 15-Mar-2026 373 Views

The imagecolortransparent() function in PHP sets a specific color in an image to be transparent. This is particularly useful when creating images with transparent backgrounds or when overlaying images. Syntax imagecolortransparent(resource $image [, int $color]) Parameters image − An image resource created by functions like imagecreatetruecolor() or imagecreate(). color (optional) − Color identifier created with imagecolorallocate(). If not specified, returns the current transparent color. Return Value The function returns the identifier of the new transparent color when a color is set. If no color parameter is provided, it returns the ...

Read More

imagecolorsforindex() function in PHP

George John
George John
Updated on 15-Mar-2026 140 Views

The imagecolorsforindex() function in PHP retrieves the RGBA color values for a specific color index in an image. This is useful when you need to analyze or manipulate colors at specific positions in an image. Syntax imagecolorsforindex(resource $image, int $index) Parameters image − An image resource created by image creation functions like imagecreate() or imagecreatefrompng() index − The color index value obtained from functions like imagecolorat() Return Value Returns an associative array containing four keys: red, green, blue, and alpha with their corresponding integer values (0-255 for RGB, 0-127 for ...

Read More

imagecolorclosest() function in PHP

George John
George John
Updated on 15-Mar-2026 147 Views

The imagecolorclosest() function gets the index of the closest color to the specified color in an image's palette. This function is particularly useful when working with palette-based images where you need to find the best match for a specific RGB color. Syntax imagecolorclosest(image, red, green, blue) Parameters image − Image resource created with image creation functions red − Red color component (0-255) green − Green color component (0-255) blue − Blue color component (0-255) Return Value The imagecolorclosest() function returns the index of the closest color in the palette of ...

Read More

imagecolorclosesthwb() function in PHP

George John
George John
Updated on 15-Mar-2026 103 Views

The imagecolorclosesthwb() function finds the index of the color that most closely matches a given RGB color using the HWB (Hue, Whiteness, Blackness) color model. This function is useful for color matching in palette−based images. Syntax imagecolorclosesthwb($image, $red, $green, $blue) Parameters $image − An image resource created by image creation functions like imagecreate() or imagecreatefromgif() $red − Red color component value (0−255) $green − Green color component value (0−255) $blue − Blue color component value (0−255) Return Value Returns an integer representing the index of the color in the image ...

Read More

imageflip() function in PHP

George John
George John
Updated on 15-Mar-2026 357 Views

The imageflip() function is used to flip an image using a given mode. This function modifies the image resource directly and is commonly used for creating mirror effects or rotating images. Syntax bool imageflip(resource $image, int $mode) Parameters $image − An image resource created using functions like imagecreatetruecolor(), imagecreatefrompng(), etc. $mode − The flip mode constant. Possible values are: IMG_FLIP_HORIZONTAL − Flips the image horizontally (left to right) IMG_FLIP_VERTICAL − Flips the image vertically (top to bottom) IMG_FLIP_BOTH − Flips the image both horizontally and vertically Return Value ...

Read More

get_browser() function in PHP

George John
George John
Updated on 15-Mar-2026 1K+ Views

The get_browser() function looks up the user's browscap.ini file and returns the capabilities of the user's browser. This function requires the browscap configuration setting in php.ini to be properly configured. Syntax get_browser(user_agent, return_array) Parameters user_agent − Optional. The name of HTTP user agent. If omitted, the current user agent is used. return_array − Optional. If set to true, the function returns an array instead of an object. Return Value The get_browser() function returns an object or array containing information about the user's browser capabilities, or FALSE ...

Read More

imagesy() function in PHP

George John
George John
Updated on 15-Mar-2026 145 Views

The imagesy() function gets the height of an image resource in PHP. It returns the height of the image in pixels or FALSE on errors. Syntax imagesy(image) Parameters image − An image resource created by one of the image creation functions like imagecreatetruecolor(), imagecreatefromjpeg(), etc. Return Value The imagesy() function returns the height of the image in pixels as an integer, or FALSE on failure. Example The following example demonstrates how to get the height of a newly created image − ...

Read More
Showing 251–260 of 789 articles
« Prev 1 24 25 26 27 28 79 Next »
Advertisements