So some time ago i decided to start learning C, i decided that doing Harward’s CS50 would be a great start , the problem is that they use their own header file in their code which is named cs50.h, and i dont really know how to link it to my code, i primarly use vim and do everything from console, currently my main pc broke so instead of coding on linux i’ve been using windows’s MSYS2. I would be grateful for any feedback and also if someone could send me some theory behind this, what are header files, how do they work, how to link them to code and overall theory behind this so i could understand the topic much better than i do currently which is almost nothing.
#include "include/cs50.h"
#include <stdio.h>
int main(void)
{
int n = get_size();
print_grid(n);
}
int get_size(void)
{
int n;
do
{
n = get_int("Size: ");
}
while (n < 1);
return n;
}
void print_grid(int size)
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
printf("#");
}
printf("n");
}
}
When it comes to how my files look it looks like this:
CS50/main.c
CS50/include/cs50.h
i also have been trying to compile it in different ways:
normally with use of only stdio.h i do it like this – gcc -o main main.c
but i also did something like this – gcc -o main main.c -iInclude if i remember correctly.
typhrenn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.