fread(buffer = struct,struct的大小,数组中struct的数量,数组)可能吗?

时间:2013-06-20 11:36:20

标签: c arrays struct fread

到目前为止我的功能看起来像这样:

int orderList (struct artikel_t * order_arr, int arr_size_order)
{
struct artikel_t akt_artikel_order;

int icount_order=0;
struct order_list {
    int lfd_nr;
    int art_nr;
    char bezeichner[MAXCHAR];
    int bestellmenge;
    float preis;
    float gesamtpreis;};


struct order_list bestellung[arr_size_order];

while (fread(&akt_artikel_order, akt_artikel_order, arr_size_order, order_arr) < arr_size_order)
{

    bestellung[icount_order].lfd_nr=icount_order;
    bestellung[icount_order].art_nr=akt_artikel_order[icount_order].art_nr
    strcpy(bestellung(icount_count).bezeichner, "akt_artikel_order.bezeichner");

    bestellung[icount_order].bestellmenge=(akt_artikel_order[icount_order].min)*4);
    bestellung[icount_order].preis=akt_artikel_order[icount_order].preis;
    bestellung[icount_order].gesamtpreis=((akt_artikel_order[icount_order].preis)*(akt_artikel_order[icount_order].min)*4);

    icount_order++;

}
}

函数orderList接收在另一个函数中创建的struct artikel_t类型的数组的第一个元素的地址,并在打开orderList之前传递给main;此数组包含arr_size_order元素。然后,函数orderList将创建struct order_list类型的新数组。然后用* orderArray指向的数据填充数组中每个结构的元素(lfd_nr,art_nr,...)。

我将编写函数的其余部分(稍后将数组发送到有用的stdout等)。

我的问题:fread函数是否正确编写并且使用fread是否合法a)从数组读取和b)读取结构?

我希望这是有道理的。

0 个答案:

没有答案
相关问题