Skip to content

Instantly share code, notes, and snippets.

View CalebCurry's full-sized avatar
💭
it's complicated

Caleb Curry CalebCurry

💭
it's complicated
View GitHub Profile
#include "5.2-libraries.h"
int square (int input)
{
return input * input * input;
}
int cube(int input)
{
return input * input * input;
}
/*
gcc -c 5.2-libraries.c
cc -c 5.2-libraries-main.c
gcc 5.2-libraries.o 5.2-libraries-main.o
./a.out
You can also get a custom name like this:
gcc -o main 5.2-libraries.o 5.2-libraries-main.o
//research makefile to make life easier
#include <stdio.h>
int square (int input)
{
return input * input;
}
int cube(int input)
{
return input * input * input;
}
#include <stdio.h>
#include <string.h>
int main()
{
//strings are just character arrays
//the string ends with \0 (null character)
//not always the last possible index in the string.
char name[20];
#include <stdio.h>
int main()
{
//arrays are pretty simple.
//It's a collection of items all of same data type
int ages[] = {1, 3, 4, 54, 34, 2};
int size = 6;
//loops. 3 main kinds
#include <stdio.h>
int main()
{
//Each loop has three pieces and it happens at distinct times
//initialization (once at beginning)
//comparison (before each iteration)
//update (at the end of each iteration)
/*
Everything inside of if is ultimately evaluated to true or false
*/
#include <stdio.h>
#include <stdbool.h>
int main()
#include <stdio.h>
int main()
{
/*
//reference - https://www.tutorialspoint.com/cprogramming/c_operators.htm
//so far we've worked with some basic operators
///////////// Plus and Minus ///////////// (unary)
+
#include <stdio.h>
#include <stdbool.h>
int main()
{
int a = 10; //integer
double b = 10.0; //double
float c = 10.0; //float (similar to double but less precise)
char d = 'a'; //string
char e[] = "The easiest way to define a string";
//First thing - Get a compiler
//#Type 'gcc' in terminal
// - gcc
/*
compile:
- gcc hello.c
Execute
- ./a.out