A Jupyter Notebook kernel for executing C language code.
Existing Jupyter C kernels often have issues with standard input (scanf).
In particular, standard input functions may not work smoothly on Windows environments.
ic-kernel improves these compatibility issues, allowing standard input/output to work correctly regardless of the OS.
- Cross-Platform: Works everywhere, including Windows, macOS, and Linux (Ubuntu).
- Jupyter Input Support: When
scanforfgetsis executed, an input box appears immediately at the bottom (Same experience as a terminal). - Infinite Loop Prevention: Even if you accidentally run
while(1), you can stop it immediately by pressing the [⏹ Stop] button in Jupyter. - Error Coloring: Compilation errors are highlighted in Red/Yellow, making it easy to identify the cause of the problem.
- Magic Commands: You can freely add math libraries or compilation options using
//%cflags -lm.
This kernel supports local PC use only. To use this kernel, you need Python and a C Compiler (GCC).
- Open your terminal (CMD) and enter the following command:
python --version
- If the version is
3.8or higher, you are good to go! - If an error occurs, download and install Python from the Official Python Website.
⚠️ Warning: You MUST check the "Add Python to PATH" box at the bottom of the installation screen!
Follow the instructions for your operating system.
- Go to the WinLibs Download Link.
- Download the latest Zip archive (UCRT runtime).
- Extract the downloaded zip file to the root of your C drive (e.g.,
C:\mingw64). - Set Environment Variables (Required):
- Search for "Edit the system environment variables" in the Windows search bar and open it.
- Click the [Environment Variables...] button -> Under [System variables], double-click
Path. - Click [New] -> Enter
C:\mingw64\binand press Enter. - Click [OK] to close all windows.
- Verify: Open a new CMD window and type
gcc --version. If the version is displayed, success!
Open the terminal and enter the following command to install Xcode Command Line Tools.
xcode-select --installOpen the terminal and install GCC using the commands below.
sudo apt update
sudo apt install build-essentialDownload this repository (folder), open a terminal inside the folder, and enter the following two lines.
# 1. Install Jupyter and required libraries
pip install .
# 2. Register the kernel (Auto-install script)
install-ic-kernelWhen you see the message "✅ Interactive C Kernel installed successfully!", you are ready.
- Type
jupyter notebookin your terminal to start it. - Click the [New] button in the top right and select Interactive C Kernel.
- Write and run(
Shift + Enter) your C code!
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age); // An input box will appear below!
printf("You are %d years old.\n", age);
return 0;
}When using headers like math.h, add the //%cflags option at the very top of your code.
//%cflags -lm
#include <stdio.h>
#include <math.h>
int main() {
printf("Square root of 2: %f\n", sqrt(2.0));
return 0;
}Try making a syntax error intentionally. The error location will be highlighted in Red.
#include <stdio.h>
int main() {
printf("I missed the semicolon") // Error!
return 0;
}