Fading Coder

One Final Commit for the Last Sprint

Solutions to the 2024 Blue Bridge Cup Provincial C++ Intermediate/Advanced Group Programming Problems

T1 - Reading Plan Problem: A book has (n) pages. On the first day, a person reads (x) pages. Each subsequent day, they read (y) pages more than the previous day. How many days are needed to finish the book? Input: Three integers (n), (x), (y) ((20 \le n \le 5000, 1 \le x, y \le 20)) separated by spa...

Handling Variable Declarations within Switch Statements in C and C++

When declaring variables inside a case block of a switch statement, specific compiler behaviors in C and C++ must be considered. The following code illustrates a commmon issue: switch (input_value) { case FIRST_CASE: int local_var = 100; case SECOND_CASE: // Additional code break; default: // Defaul...

Implementing a Custom Linked List with a Dummy Head Node

Problem Description LeetCode Problem Link: 707. Design Linked List You can choose to use a singly linked list or a doubly linked list to design and implement your own linked list. A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next...

Collecting Windows Hardware and OS Information in C/C++ using Win32 APIs, Registry, and WMI

Win32/Registry-based approach Direct Win32 calls and registry queries provide fast access to operating system and hardware metadata. The code below wraps commonly used queries (OS/service pack, CPU, memory, NICs, disks, GPU). SystemProbe.h #pragma once #include <afxtempl.h> class SystemProbe {...

Reading an RTSP stream and remuxing to FLV with FFmpeg in C++

The program below opens an RTSP source, probes its streams, and remuxes packets direct to an FLV file without decoding. Timestamps are rescaled to the destination time base and packets are interleaved before writing. Initialize FFmpeg networking and open the input with RTSP options (e.g., TCP transp...

Streaming XML in Qt with QXmlStreamReader and QXmlStreamWriter

Streaming XML in Qt with QXmlStreamReader and QXmlStreamWriter aligns with SAX-style processing: data is consumed sequentially without building an in-memory tree. Compared to the legacy DOM and SAX APIs, the streaming classes are lighter, faster for large documents, and still easy to use for both re...

Building the Smallest Win32 GUI Application in C++ with Visual Studio

Project setup in Visual Studio File → New → Project Select "Installed" → "C++" → "Windows Desktop" → "Windows Desktop Wizard" (or "Win32 Project" on older VS) Name the project (for example, MinimalWin32App) Choose "Windows application" and...

C++ OpenGL/GLUT Solar System Simulation with Lighting and Camera Controls

C++ OpenGL/GLUT programs render to a window created and driven by GLUT’s event loop. OpenGL performs drawing; GLUT supplies cross‑platform windowing, input, and callbacks. Install GLUT (Ubuntu/Debian): sudo apt-get update && sudo apt-get install freeglut3 freeglut3-dev A minimal GLUT program...

Linux C/C++ Socket Programming by Example: TCP/UDP Chat, select, Threads, Timers, and fork

TCP Chat over a Local Network Minimal TCP Echo Server (C) #include <arpa/inet.h> #include <errno.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h&...

Qt Widget-Based Calculator: UI Validation, Infix Parsing, RPN Conversion, and Evaluation

User interface uses QWidget as the top-level window, QLineEdit to show and edit the expression/result, and QPushButton for keypad input. Normalize user input as it’s typed to simplify later evaluation. Parentheses are tracked sothat a closing parenthesis is only allowed when a matching opening paren...