Message from C, C++ discussions

December 2019

— Do you know how to do it?


I suggest you don't ask for people to do your homework. Try and if you cannot manage, come back and ask for help

— Yes

— It's not homework I'm doing, I'm just trying to simplify my life when doing my homework (we are working on matrices and printing out a matrix comes out multiple times)

Message permanent page

— The issue is I've created the function that does that

— But it only works within the same file of the main program

— So your problem rather is: how to call a function from a different file in C

— If it's in a separate file I cannot find a way to make it work because I guess it gets interpreted as trying to make a variable size matrix (which I know I cannot create without pointers)

Message permanent page

— Well, yes, but actually no, rather how to make the same function in a different file that is, in a way, a library of functions that more or less do the same thing

Message permanent page

— You will, indeed, run into that very problem, which I advise to solve using the very solution you know is tiresome. Sadly, C is more of a syntactic sugar on top of assembly code than a proper programming language

Message permanent page

— So do I just open the file, copy paste the function in the main program and call it a day? that's how I've been dealing with it

Message permanent page

— In C, you need to write both a header file (contains the definitions of the functions and types) and an implementation file. The header generally have a .h extension and the implementation a .c extension

Message permanent page