Ayush Gupta

Ayush Gupta

433 Articles Published

Articles by Ayush Gupta

Page 5 of 44

Convert the string of any base to integer in JavaScript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 199 Views

The parseInt() function in JavaScript converts strings representing numbers in any base (2-36) to decimal integers. This is useful when working with binary, octal, hexadecimal, or other numeral systems. Syntax parseInt(string, radix); Parameters string − The value to parse. If not a string, it's converted using the ToString method. Leading whitespace is ignored. radix − An integer between 2 and 36 representing the base of the numeral system. If omitted, defaults to 10 (except for strings starting with "0x" which default to 16). Examples Converting Different Bases to Decimal ...

Read More

Differences between web-garden and a web-farm in Javascript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 452 Views

In web application deployment, understanding the difference between Web Garden and Web Farm architectures is crucial for scaling JavaScript applications effectively. Both approaches handle increased traffic differently through process-based and server-based scaling respectively. What is a Web Garden? A Web Garden is a web hosting system that comprises multiple "processes" running on a single server. This means we have one physical machine executing multiple worker processes to handle incoming requests concurrently. Single Server (Web Garden) Process 1 ...

Read More

Iseek() in C/C++ to read the alternate nth byte and write it in another file

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 811 Views

The lseek() function in C is used to change the file offset (position) of the file descriptor. It allows us to read data from specific positions in a file by moving the file pointer. In this tutorial, we'll demonstrate how to read alternate nth bytes from one file and write them to another file. Note: This program requires file I/O operations with system calls that may not work in all online compilers. Create "start.txt" with sample content before running. Syntax off_t lseek(int fd, off_t offset, int whence); Parameters fd − ...

Read More

Integer literal in C/C++ (Prefixes and Suffixes)

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 2K+ Views

Integer literals in C are numeric values written directly in the source code to represent integer constants. They can be modified using prefixes to specify the base (decimal, octal, hexadecimal, binary) and suffixes to specify the data type (int, long, unsigned, etc.). Integer literals are of two types − Prefixes − Indicate the number base. For example, 0x10 represents hexadecimal value 16. Suffixes − Specify the data type. For example, 123LL represents a long long integer. Syntax // Prefixes decimal_literal (no prefix) 0octal_literal (prefix ...

Read More

INT_MAX and INT_MIN in C/C++ and Applications

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 3K+ Views

In C programming, INT_MAX and INT_MIN are predefined macros that represent the maximum and minimum values that can be stored in an int variable. These macros are defined in the header file and are essential for boundary checking and initialization in various algorithms. Syntax INT_MAX /* Maximum value for int */ INT_MIN /* Minimum value for int */ Basic Example Let's see how to use INT_MAX and INT_MIN in a simple program − #include #include int main() { ...

Read More

Creating a C/C++ Code Formatting tool with help of Clang tools

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 258 Views

In this tutorial, we will be discussing how to create a C/C++ code formatting tool using Python and clang-format. This tool automatically formats all C/C++ source files in a project directory according to specified coding standards. Installation Requirements: sudo apt install python3 sudo apt install clang-format How It Works The tool works by recursively scanning directories for C/C++ files and applying clang-format to each file. It uses Python's os.walk() to traverse directories and identifies source files by their extensions. Example: Python Code Formatter Script Create a Python file named format_code.py in your project ...

Read More

Create Directory or Folder with C/C++ Program

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 4K+ Views

Creating a folder or directory on your computer is an important task in programming. A directory is like a container that helps store and organize files. In C, you often need to create directories to store data, logs, or configuration files. Creating directories makes file management easier. For example, if your program needs to store logs, it should check if a "logs" folder exists. If not, it can create the folder automatically, so you don't have to do it manually. In this article, we'll show you how to create a directory in C using the mkdir() function. ...

Read More

Core Dump (Segmentation fault) in C/C++

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 5K+ Views

Core dump (segmentation fault) is a runtime error that occurs when a program tries to access memory that it isn't allowed to access or tries to access memory in a way that isn't allowed. This results in the operating system terminating the program abnormally to prevent potential system damage. A segmentation fault typically happens when code tries to write to read-only memory, accesses corrupt memory locations, or violates memory access permissions. Syntax /* Common scenarios that cause segmentation faults */ char *ptr = NULL; *ptr = 'A'; ...

Read More

Converting Strings to Numbers in C/C++

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 330 Views

In C programming, converting strings to numbers is a common task that can be accomplished using several standard library functions. C provides multiple approaches to convert string representations of numbers into their corresponding numeric values. Syntax int atoi(const char *str); long atol(const char *str); double atof(const char *str); long strtol(const char *str, char **endptr, int base); double strtod(const char *str, char **endptr); Method 1: Using atoi() for Integer Conversion The atoi() function converts a string to an integer value − #include #include int main() { ...

Read More

Convert a String to Integer Array in C/C++

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 3K+ Views

In C, converting a comma-separated string to an integer array involves parsing the string character by character and extracting numeric values. This process requires traversing the string, identifying delimiters (commas), and converting individual number substrings to integers. Syntax // Function to convert string to integer array void convertStringToArray(char str[], int arr[], int *size); Example: Using Character-by-Character Parsing This approach traverses the string and builds integers by accumulating digits until a comma is encountered − #include #include void convertStringToArray(char str[], int arr[], int *size) { int i = 0, j = 0, num = 0; int len = strlen(str); for (i = 0; i = '0' && str[i]

Read More
Showing 41–50 of 433 articles
« Prev 1 3 4 5 6 7 44 Next »
Advertisements