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 983 of 2109
trunc() , truncf() , truncl() in C language
In C, the trunc(), truncf(), and truncl() functions are used to truncate floating-point values, removing the fractional part and returning only the integer portion. These functions are part of the math.h library and are available in C99 and later standards. Installation: These functions require C99 or later. Compile with gcc -std=c99 -lm to link the math library. Syntax double trunc(double x); float truncf(float x); long double truncl(long double x); Parameters x − The floating-point value to be truncated Return Value Returns the truncated value (integer part) as ...
Read Moresetjump() and longjump() in C
In this section, we will see what are the setjmp() and longjmp() functions in C. The setjmp() and longjmp() functions are located in the setjmp.h library and provide a way to perform non-local jumps in C programs. Syntax #include int setjmp(jmp_buf env); void longjmp(jmp_buf env, int val); Parameters env − A buffer of type jmp_buf that stores the calling environment val − An integer value to be returned by setjmp() when longjmp() is called Return Value setjmp() − Returns 0 when called directly, or the value specified ...
Read MoreHow to Send HTTP Response Code in PHP
In PHP, you can send HTTP response codes to communicate the status of a request to the client. This is essential for proper web communication and helps browsers, APIs, and other clients understand how to handle the response. Using http_response_code() Function The http_response_code() function is the simplest method to set HTTP response codes in PHP 5.4+: This function must be called before any output is sent to the client. You can also retrieve the current response code by calling it without parameters: Using header() Function The header() ...
Read MoreHow to measure time taken by a function in C?
Here we will see how to calculate the time taken by a process or function in C. For this problem, we will use the clock() function. The clock() function is present in the time.h header file. To get the elapsed time, we can get the time using clock() at the beginning, and at the end of the tasks, then subtract the values to get the differences. After that, we will divide the difference by CLOCKS_PER_SEC (Number of clock ticks per second) to get the processor time. Syntax clock_t clock(void); Example Here's a complete ...
Read MoreHow to change the output of printf() in main()?
Here we will see how to change the output of the printf() function from main(). We will define a macro that will modify all printf() statements to use a different value than what is passed to it. We will use the #define macro to accomplish this task. This macro will be defined inside a function, allowing us to control when the printf() behavior changes. By calling the function from main(), we can control exactly when printf() starts behaving differently. Syntax #define printf(format, value) printf(format, replacement_value); Example In this example, we define a macro ...
Read MoreHow to Send a GET Request from PHP
In PHP, you can send GET requests to retrieve data from external APIs or web services using several built−in methods. Each approach offers different levels of functionality and control over the request process. Using file_get_contents() The simplest method for sending GET requests uses the file_get_contents() function, which is ideal for basic requests without custom headers or complex configurations ? Note: Ensure that allow_url_fopen is enabled in your PHP configuration for this method to work with remote URLs. With Context Options You can customize the request by creating a context ...
Read MoreAssigning multiple characters in an int in C language
The character type data is stored by its ASCII value internally in C. If we want to print a single character as integer, we will get the ASCII value. But when we are trying to print more than one character using a single quote, then it will print some strange output. Syntax int variable = 'character'; int variable = 'multiple_chars'; // Non-standard behavior Example Please check the following program to get the idea − #include int main() { printf("%d", 'A'); printf("%d", ...
Read MoreAddress of a function in C or C++
In C programming, every function is stored in the computer's memory and has a unique memory address, just like variables. We can access and display these function addresses to understand how functions are stored in memory. Syntax functionName // Returns address of the function (void*)functionName // Cast to void pointer for printing Accessing Address of a Function To access the address of a function, we use its name without parentheses. When we write hello() with parentheses, we're calling the function. But when we write just hello, it ...
Read MoreHow to Select and Upload Multiple files with HTML and PHP, using HTTP POST
HTML and PHP are commonly used together to create dynamic web applications. When it comes to uploading multiple files from an HTML form to a PHP script, the standard method is to use the HTTP POST method with multipart form encoding. HTML Form for Multiple File Upload Create an HTML form that allows users to select multiple files for uploading. Use the element with the multiple attribute to enable multiple file selection. Set the form's enctype attribute to "multipart/form-data" to handle file uploads − Multiple File Upload ...
Read MoreImplicit initialization of variables with 0 or 1 in C
In C programming, uninitialized variables and partially initialized arrays follow specific rules for implicit initialization. Global variables, static variables, and array elements are automatically initialized to zero, while local variables contain garbage values if not explicitly initialized. Syntax // Global variables - implicitly initialized to 0 int global_var; int global_array[SIZE]; // Partial array initialization - remaining elements become 0 int array[SIZE] = {value1, value2, ...}; Example 1: Global Variables Implicit Initialization Global and static variables are automatically initialized to zero − #include int x, y; ...
Read More