-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture 7 - example part2-headers #10
Comments
The purpose of // file.c
int main()
{
int a = square(2);
}
int square(int x)
{
return x*x;
} If you tried to compile this code you will end up with at least a warning if not a compile error because by the time the compiler reaches " // file.c
int square(int x); // a function prototype
int main()
{
int a = square(2); // compiler now knows that square() is a function defined somewhere
}
int square(int x)
{
return x*x;
} Header files are typically used to store function prototypes for the function defined in the corresponding source file. So if |
I understand that. But wasn't the point of demo to show how to link |
I just reread your initial question and realized that I misunderstood. (Currently bouncing around panicked last-minute questions from other students.) You are correct: the file #include "sub1.h" at the top, not |
Gotcha. Thanks! |
Reopening because other students may want to read. |
I know this lecture was a week ago, but it's been bugging me. In the demo example of showing how
.h
files are linked tomain.c
, I think you want#include "sub1.c"
to be#include "sub1.h"
instead, correct?The text was updated successfully, but these errors were encountered: