return;

C programming guide

Sanic fast setup

This is a super condensed version of the setup, meant to give a quick overview and walkthrough. Read the comprehensive setup if you want more context and explanations about things.


Setup tools

Open command line

Windows (CMD): press Win+R, then type cmd into the box.

Linux (Terminal): press Ctrl+Alt+T.

To find out what's in the current folder, type dir on Windows or ls on Linux.

Type cd foldername to enter a folder, cd .. to exit folder.

Install the compiler

You need a compiler to turn your code into a program, and you need to use the compiler through command line commands. We'll use GCC.

Windows You'll need to install MingW (which includes GCC):
https://sourceforge.net/projects/mingw/

Alternately, you can get an unofficial version from here without having to enable javascript:
https://nuwen.net/mingw.html (mingw-XXX-without-git.exe)

Linux You might already have GCC. If not you can install it on some Linux distributions by typing sudo apt install gcc into the command line.

On the command line, type gcc --version to test if it works, you should get some information about the GCC version.


Make a test program

Save the code below as "main.c":

#include <stdio.h>
int main () {
	printf("Bag of biscuits\n");
	return 0;
}

Windows Save the below as "build.bat" into the same folder:

@ECHO OFF
gcc main.c -o testprogram   && (
	testprogram
)

Linux Save the below as "build.sh" into the same folder:

#!/bin/sh
if   gcc main.c -o testprogram   ; then
	./testprogram
fi

On the command line, navigate to the folder and type chmod u+x build.sh to make the build script executable.

On command line, navigate to the folder that has your build script and main.c code file. Type build on Windows, or ./build.sh on Linux, the build script will create your program and immediately runs it. The program should print "Bag of biscuits" onto the command line.