Having Some Trouble With Adding A Library?

This is a discussion on Having Some Trouble With Adding A Library? within the C Programming forums, part of the General Programming Boards category; Hi, I'm very new to C and I'm following on online course. I'm aware that there may have been other ...

Having Some Trouble With Adding A Library?

Hi, I'm very new to C and I'm following on online course. I'm aware that there may have been other threads similar to this but I can't understand the solutions for those threads. I'm following the CS50 course, so I was given two files, cs50.c and cs50.h. I am aware the ".c" file is a C file, and the ".h" is a header file, but I'm not sure what to do with them. In the cs50.c file there is something that says this:

It looks like they are just providing the source code which you must then transform into a library. They expect you to do that from the command line but since you are on Windows, you could do it using codeblocks. Just make a new project and select STATIC LIBRARY from the options that appear. Add the two files to the project and then build it. Codeblocks should automatically build the library file libcs50.a for you in the folder where the project is.

1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.