0

I don't get an error message however it does not print "Dieser Artikel ist vorhanden" when I input the same "Artiklenummer" although it should. What did I do wrong?

 int main()
    {
    printf("                                LAGERVERWALTUNGSSYSTEM \n");
    printf("                             DRUECK DIE 1 FUER Einlagerung \n" );
    printf("                             DRUECK DIE 2 FUER Auslagerung \n" );

    char artnr[50],menge[50],me[50],neu[50],date[50];
    int zahl, calcam, id, sub,amount;
    int lenm = 0;
    int len = 0;
    int greatlen = 0;
    int result = 0;
    char str[5][5][5];
    int mengen[10];
    int a = 1;
    int s = 0;
    while(a > 0){
     printf("Geben sie eine Zahl ein:");
     scanf("%d", &zahl);
     if(zahl == 1){
       printf("Geben sie ein:\nArtikelnr.:");
       scanf("%s",&artnr);
       strcpy(str[s][0],artnr);
       len= len+1;
       printf("Menge:");
       scanf("%d",&mengen[lenm]);
       lenm = lenm+1;
       printf("Mengeneinheit:");
       scanf("%s",&me);
       strcpy(str[s][1],me);
       len= len+1;
       printf("Datum:");
       scanf("%s",&date);
       strcpy(str[s][2],date);
       len= len+1;
     };
     s =s+1;
     greatlen = greatlen +1;
     if(zahl == 2){
       printf("Welche Ware wollen sie auslagern?:\nArtikelnr.:");
       scanf("%s",&neu);
       printf("Welche Menge wollen sie auslagern?:");
       scanf("%d",&sub);
       for(int i= 0; i<len;i++){
           if(str[j][0] == neu){
                printf("Dieser Artikel ist vorhanden");
           }
          };
        };

    };


    return 0;
   }
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • 1
    Your program is incomplete without headers, and you have a typo `j` index which means you program doesn't compile. Use English when posting here. Minimize scope of variables. Use a struct for data that belongs together. Check return values of functions, in particular scanf() otherwise you may be operating on unitialized data. Use a for loop instead of while when iterating. Use constants instead hard-coding 50. – Allan Wind Jan 05 '23 at 08:24
  • What exactly is "the same Artiklenummer"? – mkrieger1 Jan 05 '23 at 08:24
  • Specify maximum field length when reading strings with `scanf("%49", &artnr);`. strpcy a string that might be 50 bytes long to a str[5][5]5] is going to end badly. Use functions. – Allan Wind Jan 05 '23 at 08:32
  • Your question title is totally misleading.... – Jabberwocky Jan 05 '23 at 08:54

0 Answers0