Skip to content

Instantly share code, notes, and snippets.

@haiiro-shimeji
Last active December 20, 2015 22:19
Show Gist options
  • Save haiiro-shimeji/6204137 to your computer and use it in GitHub Desktop.
Save haiiro-shimeji/6204137 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char** argv) {
//関数定義の前に関数利用のコードがあるとコンパイルエラー.
hoge();
}
void hoge() {
puts("hoge");
}
#include <stdio.h>
//関数定義が利用の前に記述されていればコンパイル可能だが
//定義を別ファイルに記述する場合などではこの手は使えない.
//また同じ関数の定義を複数回行うとエラーになる.
void hoge() {
puts("hoge");
}
int main(int argc, char** argv) {
hoge();
}
#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