//Basic argument structure.
$
gcc 'fileName.c' -o 'outputFileName' 'flags'
//Note: Each arguement besides the first is optional.
//Examples to compile and run
$
gcc lab1.c
$
./a.out
//Or to rename the compiled executable use the -o flag
$
gcc lab1.c -o lab1
$
./lab1
//Or to compile multiple files
$
gcc lab1.c runner.c functions.c -o lab1
$
./lab1
//Creates and assigns a new variable of float data type.
float x = 734.734;
//Creates and assigns a new variable of double data type.
//The exact memory of float and double vary ammong compilers.
//For this class float will almost exclusively be used.
//But double has double the memory limit of float.
double x = 734.734734734734;
//Defines a new datatype called "Person"
typedef struct {
int age;
char name[20];
} Person;
//Create a new variable joe of type Person
Person joe;
joe.age = 22;
//Note you cannot directly reassign arrays.
//You will need to use the strcpy function.
//This works like you would think joe.name = "Joe" would.
strcpy(joe.name, "Joe");
//Say we want a char array of size 5
int* numArray = malloc(sizeof(int) * 5);
//Note malloc takes in one parameter the size of desired bytes
//and it returns a pointer to the memory block allocated
//We can now treat numArray as a int array of 5.
//Lets init a value and a pointer to it.
int x = 5;
//To "refrence" a values memory loaction use the & sign.
int* xPtr = &x;
//Now we could do things like pass xPtr into a function.
//Then we could change x ouside our current scope.
//To "derefrence" a pointer to get the value use the * sign.
*xPtr = 99;
//Recall arrays are just pointers to the first index.
int array[] = {1,2,3,4,5};
//So if we just derefrence "array" we get 1.
printf("%d", *array);
//Outputs: 1