Last active
December 20, 2015 22:19
-
-
Save haiiro-shimeji/6204137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char** argv) { | |
//関数定義の前に関数利用のコードがあるとコンパイルエラー. | |
hoge(); | |
} | |
void hoge() { | |
puts("hoge"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
//関数定義が利用の前に記述されていればコンパイル可能だが | |
//定義を別ファイルに記述する場合などではこの手は使えない. | |
//また同じ関数の定義を複数回行うとエラーになる. | |
void hoge() { | |
puts("hoge"); | |
} | |
int main(int argc, char** argv) { | |
hoge(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
//実装の代わりに関数宣言を記述することで、 | |
//コンパイルが通るようになる. | |
//同じ宣言が複数回記述してあっても大丈夫 | |
//通常はヘッダファイル"*.h"に記述する. | |
void hoge(); | |
int main(int argc, char** argv) { | |
hoge(); | |
} | |
//関数利用コードのあとに書いても大丈夫. | |
//また、実装を別のファイルに書いてもコンパイルは通る | |
void hoge() { | |
puts("hoge"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment