-3

I have a problem in this code segment printf("\nIn Func: %s", (*article[ctr]).artname);

I use Code:Blocks and get the error "undefined reference to WinMain@16", article is a pointer array shouldn't I access it just by dereferencing it? I also tried with -> but without success.

May I disobey something?

Thanks for help, I added the complete code below.

Header-File:

#ifndef _LAGER_H
#define _LAGER_H

#define MAXCHAR 40

#define lagerdateiname "lager.dat"


struct artikel_t
{
  int artnr;
  char artname[MAXCHAR];
  float preis;
  int bestand;
  int min;
};

#endif

Code-File:

#include "lagdat.h"
#include <string.h>

#include <stdio.h>

int bestellMenge(struct artikel_t *article[], int len)
{
    int errCode;
    int retVal;
    int ctr = 0;
    struct artikel_t art;

    unsigned int writtenArticles = 0;
    unsigned int leftArticles = 0;

    errCode = openLager();



    if(!errCode)
    {
        int readOK;

        while(!(readOK = readNext(&art)) && ctr < len)
        {
            if(art.bestand < art.min)
            {
                article[ctr] = &art;
                ctr++;
                writtenArticles++;


                printf("\nIn Func: %s", (*article[ctr]).artname);
            }
        }

    }

}
Dominik
  • 25
  • 5

1 Answers1

0

You have to print before ctr++ as below. Currently you are trying to point an article object what you did not fill it

            article[ctr] = &art;
            printf("\nIn Func: %s", (*article[ctr]).artname);

            ctr++;
            writtenArticles++;
avatli
  • 610
  • 6
  • 16