Possible Duplicate:
What is the difference between a definition and a declaration?
I am confuse about the function declare on head file. does this is same as java, declare function on one file,in that that file has function also has method.
does in C, make the function and method in two different files?
here is a example:
song.h
typedef struct {
int lengthInSeconds;
int yearRecorded;
} Song;
Song make_song (int seconds, int year);
void display_song (Song theSong);
song.c
#include
#include "song.h"
Song make_song (int seconds, int year)
{
Song newSong;
newSong.lengthInSeconds = seconds;
newSong.yearRecorded = year;
display_song (newSong);
return newSong;
}
void display_song (Song theSong)
{
printf ("the song is %i seconds long ", theSong.lengthInSeconds);
printf ("and was made in %i\n", theSong.yearRecorded);
}
Can I write those two functions on just one file?
Thanks. I am new to C.
Regards.
Ben.
No comments:
Post a Comment