-1

私はダブルリンクリストに取り組んでいます。.h & .c ファイルを作成しました。

//.h -file

typedef struct Data_t{
        int d_sz;
        void * data;
    }data_t, * data_ptr_t;

    typedef struct List_t{
            int index;
            struct List_t * next;
            struct List_t * prev;
            data_t * d;
    }list_t, * list_ptr_t;

// .c ファイル

/**
 * Inserts a new element containing 'data' in 'list' at position 'index'  and returns a pointer to the new list. 
 * If 'index' is 0 or negative, the element is inserted at the start of 'list'. 
 * If 'index' is bigger than the number of elements in 'list', the element is inserted at the end of 'list'.
 */
list_ptr_t list_insert_at_index( list_ptr_t list, data_ptr_t data, int index){

                            // add data to newlist
        return newlist;
    } 

// 。主要

int i;
    int value;


    data_ptr_t h;
    list_ptr_t l;
    printf("Enter a value:");
    scanf("%d",&value);

    l = list_insert_at_index( ? , ?, 0);

// 関数を機能させるには? この機能を正確に何にしますか?この機能のみである必要があります。

4

2 に答える 2

2

test.cたとえば、.h ファイルと.c ファイルの名前が次の場合、test.hこれを main.cpp の先頭に置きます。

#include "test.h"

次に、ヘッダーファイルで定義したすべての関数を使用できます

于 2013-03-18T20:23:15.187 に答える
1

あなたの主にあなたがする必要がある

#include "YOUR.H"

YOUR.H は、投稿の上部に表示する .h ファイルの名前です。

これにより、YOUR.MAIN.C は、指定されたデータ型と関数がコンパイル/リンクされたときに存在するという「約束」を与えます。YOUR.c とリンクするメインを準備するのに十分なデータが得られます。

コンパイルするときは、必ず 3 つのファイルすべてをコンパイラに渡してください。それはうまくいくはずです。あなたが試したことの詳細は、より具体的な答えを得るのに役立ちます.

于 2013-03-18T20:24:09.103 に答える