ByteC v2.0: The Pocket C & C++ Survival Guide
Welcome. If your college C programming course started this week, you do not own a laptop, and the black Termux screen looks like a 1980s hacker movie, you are in the right place. ByteC turns your Android phone into a 120MB C and C++ studio with plain-English commands, an offline error tutor, and one-command PDF/DOC lab reports.
Never touched Linux before? Read Zero-to-One: What Even Is a Terminal? first. It takes two minutes and saves hours of confusion.
Zero-to-One: What Even Is a Terminal?
On a phone, you tap icons to open apps. A terminal (also called the command line or shell) skips the icons and lets you send text messages to the operating system. You type a command, press Enter, and the phone runs it and prints the answer back.
Why Can't My Phone Run C Code Right Away?
When you write a C program, you write human-readable text like printf("Hello\n"); inside a file named lab1.c. Your phone's processor (the CPU) does not speak English or C. The CPU understands raw binary numbers (machine code) and nothing else.
To bridge that gap, you use a compiler (ByteC uses Clang, wrapped so gcc and g++ work too). The compiler reads your lab1.c text file, checks whether you forgot any semicolons, and translates the whole thing into a binary executable that the CPU can run.
| Term | What It Means in Plain English |
|---|---|
Source File (lab1.c) |
The recipe you write in C or C++ text. |
Compiler (clang / gcc) |
The strict translator that checks your grammar and converts C text into CPU machine code. |
| Binary / Executable | The finished program produced by the compiler. |
Standard Input (stdin) |
The stream of characters you type on your keyboard when scanf waits for input. |
Standard Output (stdout) |
The text your program prints back to the terminal screen via printf. |
1-Click Termux Setup
Follow these four steps once. The entire installation takes about two minutes and uses 120MB of storage instead of a 5GB Ubuntu container.
Why F-Droid Instead of Google Play Store: Do not install Termux from the Google Play Store. The Play Store build is frozen on an obsolete SDK policy and its package servers are dead. Always download Termux from F-Droid or GitHub Releases.
Download and install the official Termux APK from f-droid.org/packages/com.termux, then open the app.
Type this command and press Enter:
termux-setup-storage
Tap Allow on the Android popup. This links ~/c_projects to /sdcard/C_Projects so your code stays safe in phone storage even if you uninstall Termux, and lets submit save PDF/DOC lab reports in your Downloads/ByteC folder.
Copy this line, long-press anywhere on the black Termux screen, tap PASTE, and press Enter:
curl -sL https://raw.githubusercontent.com/0xOpCode/ByteC/main/install.sh | bash
Activate the new commands and touch bar:
source ~/.bashrc
bytec
The 6 Magic Words (code, run, explain, check, fix, submit)
Traditional Linux makes you memorize flags like gcc -Wall -Wextra lab1.c -o lab1 -lm && ./lab1. ByteC v2.0 gives you six single-word commands. Even better: ByteC remembers the last file you edited in ~/.bytec/.last_file, so you can run these commands without retyping the filename.
Creates a new C or C++ file (or opens an existing one) in Neovim. Run it with no arguments to pick from 18 lab templates.
code lab1.c
Compiles and executes your program in one step. If compilation fails or crashes, it calls explain for you.
run lab1.c
Your offline C tutor. Translates compiler errors and Segmentation fault crashes into plain English with before/after fixes.
explain lab1.c
Pre-submission verifier. Scans for classic C bugs, kills infinite loops after 5 seconds, and runs multi-case tests.
check lab1.c
Formats messy indentation into clean college Allman brace style and checks syntax in one step.
fix lab1.c
Runs your program, captures inputs and outputs, and saves formatted .doc and .pdf lab reports in Downloads/ByteC.
submit lab1.c
How explain, check, and submit Save Your Grades
1. explain: The Offline Compiler & Crash Translator
Compilers were written by systems engineers for other systems engineers. When you forget a semicolon on line 9, Clang points at line 10 and complains about something unrelated. When you forget & in scanf, your program dies with Segmentation fault and tells you nothing.
explain runs 100% offline across three stages:
- Stage 1 (Static Capture): Runs Clang with strict diagnostics (
-Wall -Wextra -Wformat -Wuninitialized) and extracts your source lines. - Stage 2 (25+ Student Error Rules): Matches mistakes like missing
;on the previous line, missing&inscanf,=instead of==inif, uninitialized stack garbage, missing headers (<stdio.h>,<stdlib.h>,<math.h>,<string.h>), and removedgets()calls. - Stage 3 (Runtime Crash Forensics): If your code compiles but crashes while running,
explaindecodes the crash signal (SIGSEGVExit 139 for bad memory access,SIGFPEExit 136 for division by zero,SIGABRTExit 134 for double free or stack overflow) and shows the crashing line and local variable state.
[EXPLAIN] Issue found in lab1.c (Line 8, Column 18)
8 | scanf("%d", age);
| ^~~
What happened:
scanf needs the memory address of 'age' so it knows where to store the number.
Passing 'age' without '&' sends its uninitialized value as a memory address,
which triggers a Segmentation Fault crash.
How to fix (Before vs After):
- Before: scanf("%d", age);
+ After: scanf("%d", &age);
2. check: 4-Layer Verifier & 5-Second Infinite Loop Guard
Every C student writes a while (i < 10) loop where i never increments. In a normal terminal, the program freezes forever until you mash Ctrl+C. When you run check lab1.c, ByteC runs four verification layers:
- Layer 1 (Static Bug Scan): Flags
scanfwithout&,fflush(stdin),void main(),gets(), uninitialized variables, andmalloc()without a matchingfree(). - Layer 2 (Memory & Bounds Protection): Compiles with stack smash protection and bounds checks.
- Layer 3 (5-Second Watchdog Timer): Runs your binary under a 5-second timeout. If your code gets stuck in an infinite loop,
checkhalts the process after 5 seconds and tells you to inspect your loop counter. - Layer 4 (Multi-Case Test Suite): Pass a test file with multiple
--- INPUT ---and--- EXPECTED ---blocks to grade your program before your professor does.
check lab1.c
check lab1.c tests.txt
3. submit: Instant .doc & .pdf Lab Reports in Downloads/ByteC
Formatting college practical records on a phone is painful. Running submit lab1.c automates the entire lab record workflow offline:
- Storage Permission Guard: Checks if
/sdcard/Download/ByteCis writable. If Termux does not have storage permission yet,submitlaunchestermux-setup-storage, waits for you to tap Allow, and creates the folder. - One-Time Student Profile: Prompts once for your Full Name, Roll Number, and Batch, saving them in
~/.bytec/student_profile.conffor all future practicals. - Live Input-Echo Transcript: Runs your program and echoes every input value next to its prompt (for example,
Enter number: 29) so the output box in your report reads like a real terminal session. - Zero-Dependency
.doc+.pdfOutput: Writes bothlab1_LabReport.doc(Word/WPS/Google Docs compatible RTF 1.5 with bordered code boxes) andlab1_LabReport.pdf(native PDF 1.4 generated offline via POSIXawk) straight into/sdcard/Download/ByteC/and fires an Android notification.
submit lab1.c
submit lab1.c -i input.txt
Surviving Neovim (Without Rebooting Your Phone)
There is an old computer science joke: "How do you generate a random string? Put a first-year student in Vim and ask them to exit."
People get trapped in Vim/Neovim because it has two main modes instead of one. Once you understand the difference between Normal Mode and Insert Mode, you will never get stuck again.
Navigation & Commands
When Neovim opens a file, you start here. Pressing letter keys does not type text on screen; keys act as shortcuts. Press i whenever you want to start typing code.
- Press
ito switch to Insert Mode. - Press
Space + rto compile and run your program. - Type
:wqand press Enter to save and exit.
Writing Code Like a Normal Editor
After pressing i, the bottom bar says INSERT. Now every key on your keyboard types characters into your file, and VS Code shortcuts like Ctrl+S, Ctrl+C, Ctrl+V, and Ctrl+Z work right away.
- Type your C/C++ code and use the 2-row symbol bar.
- Press
Ctrl + sto save and format in Allman style. - Tap
ESCon the touch bar to return to Normal Mode.
Complete Neovim v2.0 VS Code Shortcut Table
| Action | Shortcut | Details |
|---|---|---|
| Compile & Run | <Space> + r or F5 |
Saves file, formats with Allman braces, compiles in $TMPDIR, runs code, and invokes explain on errors |
| Start Typing (Insert Mode) | i |
Switches from Normal Mode into Insert Mode |
| Command Mode (Normal Mode) | ESC |
Returns from Insert/Visual Mode to Normal Mode |
| Save & Format | Ctrl + s |
Saves file and formats braces in college Allman style |
| Copy / Paste / Cut | Ctrl + c / Ctrl + v / Ctrl + x |
Copies, pastes, or cuts selection using the Android/system clipboard |
| Select All | Ctrl + a |
Highlights the entire file in Visual Mode |
| Toggle Comment | Ctrl + / |
Comments or uncomments the current line or visual selection with // |
| Undo / Redo | Ctrl + z / Ctrl + y |
Undoes or redoes changes across Normal and Insert modes |
| Select Word | Ctrl + d |
Selects word under cursor and jumps to next match |
| Floating Terminal | Ctrl + j |
Opens or hides a pop-up shell terminal inside Neovim |
| File Explorer / Find File | <Space> + e / <Space> + ff |
Toggles sidebar directory tree or fuzzy file finder |
| Save & Quit | ESC then :wq + Enter |
Writes file to disk and exits to terminal |
| Discard Changes & Quit | ESC then ZQ (or :q) |
Closes Neovim without saving edits |
Upgraded 2-Row C Symbol Touch Bar
Phone keyboards hide C operators across three sub-menus. ByteC configures a 2-row hardware toolbar above your keyboard with every token required for headers, pointers, format strings, and bitwise logic:
Row 1: [ ESC | TAB | CTRL | ALT | { | } | ( | ) | ; | " ]
Row 2: [ LEFT | DOWN | UP | RIGHT | # | < | > | & | * | = ]
Swipe up or long-press on the touch bar keys to insert secondary brackets and operators ([, ], \, |, /, -, _).
The 3 Classic C Traps (Read Before Lab 1)
C gives you direct access to memory and trusts that you know what you are doing. Here are the three traps that catch every beginner in week one, and how to beat them.
scanf Ampersand (&) Trap
When you call printf("%d", age);, C reads the value stored inside age. When you call scanf("%d", &age);, scanf needs to put a new number into the variable, so it requires the house address in memory where age lives (&age).
If you forget the & and write scanf("%d", age);, C takes whatever random garbage number is inside age (say, 4198400) and tries to write your keyboard input to memory address 4198400. The operating system catches your program trespassing and kills it with Segmentation fault.
int age;
scanf("%d", age); // CRASH: Sends uninitialized value as a memory address
scanf("%d", &age); // SAFE: Sends the memory address of 'age'
char name[50];
scanf("%49s", name); // EXCEPTION: An array name already points to its address
=) vs Comparison (==) Inside if
In math class, = means "are these two things equal?". In C, a single = means "shove the number on the right into the variable on the left". To compare two values, you need a double equals sign: ==.
If you write if (marks = 100), C overwrites marks with 100, evaluates 100 as true (every non-zero number in C is true), and runs the if block every single time.
if (marks = 100) // BUG: Overwrites marks with 100, condition is always true
{
printf("Full marks\n");
}
if (marks == 100) // SAFE: Compares marks against 100 without changing it
{
printf("Full marks\n");
}
0 to n - 1
When you declare int scores[5];, C reserves five integer slots in a row. Because an index measures how far to step from the start of the array, the first slot is at offset 0, and the fifth slot is at offset 4.
There is no scores[5]. Writing to scores[5] scribbles over whatever variable sits next to the array on the stack.
int scores[5] = {10, 20, 30, 40, 50};
// BUG: Using <= 5 steps onto scores[5], which is out of bounds
for (int i = 0; i <= 5; i++) { ... }
// SAFE: Valid indices for size 5 are 0, 1, 2, 3, 4 (i < 5)
for (int i = 0; i < 5; i++)
{
printf("%d\n", scores[i]);
}
18 Built-in Lab & DSA Templates
Start any college practical with a working, well-commented reference program using code lab.c -t <name>. Filter or search the 18 built-in templates below:
| Template | Lang | Command | What It Covers |
|---|---|---|---|
hello |
C | code lab.c -t hello |
Standard main(), command-line arguments, formatted output |
linkedlist |
C | code lab.c -t linkedlist |
Single-link list creation, insert, delete, search, memory cleanup |
doublylinkedlist |
C | code lab.c -t doublylinkedlist |
Double-link list head/tail insertion, deletion, forward and reverse traversal |
stack |
C | code lab.c -t stack |
Array stack push, pop, peek, overflow and underflow guards |
queue |
C | code lab.c -t queue |
Circular queue enqueue, dequeue, wrap-around index arithmetic |
binarytree |
C | code lab.c -t binarytree |
Binary Search Tree insert, key lookup, inorder, preorder, postorder |
graph |
C | code lab.c -t graph |
Graph representation with Breadth-First Search (BFS) and Depth-First Search (DFS) |
sort |
C | code lab.c -t sort |
Bubble sort, Selection sort, and Insertion sort with comparison counters |
quicksort |
C | code lab.c -t quicksort |
Divide-and-conquer QuickSort partition and MergeSort routines |
searching |
C | code lab.c -t searching |
Linear scan, iterative Binary search, and recursive Binary search |
recursion |
C | code lab.c -t recursion |
Factorial, Fibonacci series, Euclidean GCD, and Tower of Hanoi |
matrix |
C | code lab.c -t matrix |
2D array matrix addition, matrix multiplication, and transpose |
pointers |
C | code lab.c -t pointers |
Call-by-reference swap, pointer arithmetic, malloc and free |
strings |
C | code lab.c -t strings |
String length, copy, compare, reverse, and palindrome check without <string.h> |
structures |
C | code lab.c -t structures |
struct student database, array of records, sorting by marks |
fileio |
C | code lab.c -t fileio |
File creation, append, EOF-safe line reading, and character/line counting |
stl |
C++ | code lab.cpp -t stl |
C++ Standard Template Library: vector, map, set, priority_queue, sort |
oop |
C++ | code lab.cpp -t oop |
C++ classes, constructors, access specifiers, inheritance, and polymorphism |
Classic CLI Tools & ByteC Studio Manager
Run bytec with no arguments to launch the interactive Studio TUI menu, or run any subcommand:
bytec # Launch interactive ByteC Studio TUI menu
bytec doctor # Check compilers, storage permissions, and git setup
bytec learn # Interactive offline C lessons and coding challenges
bytec resources # Print curated C, C++, DSA, and Linux learning links
bytec cheatsheet printf # Offline reference (printf, pointers, strings, loops, dsa, keys)
bytec backup # Save zip/tar backup of ~/c_projects into /sdcard/Download/
bytec update # Update ByteC tools and Neovim configuration
Free Learning Roadmaps & Resources
Bookmark these free books, visualizers, and interactive courses. Every resource below works well on mobile browsers.
1. C Programming (Zero to Hero)
The funniest, clearest free book on C ever written. Covers everything from printf to pointers and structs without dry textbook jargon.
Short, interactive browser lessons covering variables, arrays, strings, pointers, structures, and linked lists.
David Malan's visual lectures on how C, RAM, pointers, stacks, heaps, and hash tables work under the hood.
Classic collection of answers to every confusing question about pointers, arrays, scanf, and undefined behavior.
2. C++ & Data Structures / Algorithms (DSA)
The gold-standard structured tutorial for modern C++, object-oriented programming, memory management, and the STL.
Step-by-step animated visualizations for Linked Lists, Stacks, Queues, Binary Trees, Graphs, and Sorting algorithms.
Practical explanations and C++ implementations of sorting, searching, dynamic programming, trees, and graph algorithms.
Complete encyclopedia for every C and C++ standard library header, function signature, and container complexity.
3. Linux, Terminal, Git & Termux Mastery
Bite-sized lessons starting at "Grasshopper" level for the command line, file navigation, permissions, and processes.
MIT's course on the tools classes forget to teach: the shell, Vim/Neovim, command-line environments, debugging, and Git.
Learn Linux terminal commands by solving a 34-level SSH treasure hunt game inside Termux.
Paste any cryptic Linux command to see a visual diagram breaking down what each flag and pipe does.
Official handbook for Termux storage setup, touch keyboard shortcuts, package management, and Android APIs.
Interactive 15-minute tutorial that builds muscle memory for Vim and Neovim movement keys.
Troubleshooting & FAQ
1. Where are my C files and lab reports saved on my phone?
Your source code lives in ~/c_projects, which links to /sdcard/C_Projects in your phone's internal storage. When you run submit lab1.c, your .doc and .pdf lab reports are saved inside /sdcard/Download/ByteC/ so you can share them on WhatsApp, Google Classroom, or email right away.
2. My touch keyboard disappeared in Termux. How do I bring it back?
Tap the center of the terminal screen. If it stays hidden, swipe the left drawer open in Termux and tap KEYBOARD, or hold Volume Up + Q to toggle the extra keys bar.
3. Why did my program print a giant random number like 32765 or -1094795586?
You declared a local variable like int sum; without setting it to 0 (int sum = 0;). Local variables in C do not start at zero; they hold whatever leftover bits were sitting in RAM before your function ran. Run explain or check and ByteC will point out the uninitialized variable.
4. How do I uninstall ByteC without losing my code?
Run bytec uninstall. It removes the CLI scripts and shell hooks while leaving all your files in ~/c_projects and /sdcard/C_Projects intact.