Memory Management: Stack vs Heap in C/C++
Program Memory Segmentation
A compiled C/C++ program utilizes memory divided into several distinct segments:
Stack segment - Automatically managed by the compiler, storing function parameters and local variables. Operates as a LIFO structure.
Heap segment - Manually allocated and freed by programmers. Unreleased memory may be reclaimed by the ...
Posted on Mon, 18 May 2026 05:47:20 +0000 by y4m4
Base Number Conversion Algorithms and Implementation
Problem B: Arbitrary Base Conversion
This code converts a number from one arbitrary base to another.
Implementation
#include <stdio.h>
#include <string.h>
// Convert from base `src_base` string `src_num` to decimal integer.
int convert_to_decimal(int src_base, const char *src_num) {
int result = 0;
int place_value = 1;
...
Posted on Mon, 18 May 2026 01:51:55 +0000 by thebluebus
Computing Sorted Squares of a Non-Decreasing Integer Array
Method 1: Square then Sort
This approach squares each element first and subsequently sorts the resulting array.
#include <stdio.h>
#include <stdlib.h>
int compareElements(const void* first, const void* second) {
int elemA = *((int*)first);
int elemB = *((int*)second);
if (elemA < elemB) return -1;
if (elemA > elemB) r ...
Posted on Fri, 15 May 2026 09:48:25 +0000 by prc
Live Streaming System Architecture for Academic Project
This document outlines the architecture and implementation details of a live streaming platform developed as an undergraduate graduation project.
1: Development Environment
Linux server configuration: debian10, gcc 10.2.1, php7.4.3, mysql 5.7.26, nginx1.15.11
Windows development environment: nginx1.15.11, php7.4.3, mysql 5.7.26 via XAMPP or sim ...
Posted on Thu, 14 May 2026 15:16:08 +0000 by fredcool
Implementing Inter-Process Communication with Signals and Message Queues
Signal Handlign Examples
1. Capturing SIGINT
This program demonstrates capturing the SIGINT signal (Ctrl+C) with a custom handler.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
void sigint_handler(int sig_num) {
if (sig_num == SIGINT) {
printf("Ctrl+C was pressed.\n" ...
Posted on Sun, 10 May 2026 01:47:56 +0000 by UrbanCondor
Practical Techniques for Common Problem Models in Lanqiao Cup Microcontroller Programming
Standardized Code Patterns for Varible Modification
1. Toggling Between 0 and 1
Use the XOR operator to switch a variable between 0 and 1 each time the code executes.
DisplayModeFlag ^= 1;
2. Cycling Through a Range of Values
Increment a variable and reset it to the starting value once it exceeds an upper limit.
if (++DisplayModeFlag == LIMIT_ ...
Posted on Fri, 08 May 2026 01:57:47 +0000 by wisewood