c-test/src/hello.c

39 lines
1.2 KiB
C

#include <stdio.h>
// #include <stdint.h>
#include <inttypes.h>
#include "math_functions.h"
// Project running in VSCode, this can be developed on Windows, Linux and Mac
// https://stackoverflow.com/questions/73328916/how-to-set-cmake-build-configuration-in-vscode
// Basic C program that I am playing around with
// https://www.geeksforgeeks.org/c-hello-world-program/
// https://www.w3schools.com/c/c_functions_parameters.php
// https://www.w3schools.com/c/c_functions.php
// This doesn't work like this for some reason
int uint16_test(){
// No value assigned
uint16_t test = -2;
// Assign a value here
test = -2;
return test;
// printf(test);
}
// https://cplusplus.com/reference/cstdio/printf/
void printf_example(){
printf ("Characters: %c %c \n", 'a', 65);
printf ("Decimals: %d %ld\n", 1977, 650000L);
printf ("Preceding with blanks: %10d \n", 1977);
printf ("Preceding with zeros: %010d \n", 1977);
printf ("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
printf ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
printf ("Width trick: %*d \n", 5, 10);
printf ("%s \n", "A string");
}