ソースファイルの作成

次は、scanner_test プロジェクトのソースファイルを作成します。

  1. [C/C++ Projects (C/C++ プロジェクト)] ビューから scanner_test プロジェクトを選択し、右クリックでコンテキスト・メニューを開きます。
  2. コンテキスト・メニューで [New (新規)] > [Source File (ソースファイル)] を選択します。ファイル名に scanner_test.c と入力し、親フォルダーはプロジェクト・フォルダー (scanner_test) のままにしておきます。
  3. [Finish (終了)] をクリックします。

エディタービューに scanner_test.c が表示されます。次のプログラムを入力します。

#include <stdio.h>

#include "scanner_test.h"

int main(void){

    printf("Hello from scanner_test.\n");

    scanner_test_func();

    return(0);

}

void scanner_test_func(){

     printf("Hello from scanner_test_func.\n");

     return;

}

編集を終えたらファイルを必ず保存してください。

次に、プロジェクト・フォルダー内に、プロジェクトのインクルード・ファイルのためのフォルダーを作成します。

  1. [C/C++ Projects (C/C++ プロジェクト)] ビューから scanner_test プロジェクトを選択し、右クリックでコンテキスト・メニューを開きます。
  2. コンテキスト・メニューで [New (新規)] > [Folder (フォルダー)] を選択します。[Folder name (フォルダー名)]scanner_test_includes と入力します。親フォルダーはプロジェクト・フォルダー (scanner_test) です。[Finish (終了)] をクリックします。
  3. [C/C++ Projects (C/C++ プロジェクト)] ビューから新しく作成した scanner_test_includes フォルダーを選択し、コンテキスト・メニューの [New (新規)] > [Header File (ヘッダーファイル)]scanner_test.h という名前のヘッダーファイルを作成します。新しく作成したフォルダー (scanner_test/scanner_test_includes) が親フォルダーになります。
  4. 最後に、エディターを使用して、scanner_test.h に次のコードを入力します。

#ifndef SCANNER_TEST_H

#define SCANNER_TEST_H 1

void scanner_test_func();

#endif