Originariamente inviato da MacApp
E' un po' difficile provare ad aiutarti per risolvere il tuo problema con così pochi indizi non credi?
;-)
Eh ci avevo pensato però ho pensato anche che pubblicare tutto il codice era esagerato :P
vabbe comunque mo posto le parti incriminate:
questo è prodotto.h
codice:
#include <iostream>
#include <cstdlib>
using namespace std;
const int DIM=50;
typedef char stringa [DIM];
typedef struct Prodotto {
stringa Cod;
stringa Descr;
int Qta;
};
typedef Prodotto * prod;
void Insert_Prod (prod &);
void Delete_Prod (prod);
Questa è la funzione del prodotto che acquisisce il codice, la descrizione e la quantità
codice:
void Insert_Prod (prod & punt) {
cout<<"\n Codice prodotto: ";
cin.ignore();
cin.getline(punt->Cod,DIM+1);
cout<<"\n Descrizione prodotto: ";
cin.ignore();
cin.getline(punt->Descr,DIM+1);
cout<<"\n Quantita' prodotto: ";
cin>>punt->Qta;
}
Mentre le due che seguono sono rispettivamente il file header riguardante il vettore (magazzino.h) e la funzione che alloca ed inizializza il vettore.
codice:
#include "prodotto.h"
typedef prod * mag;
void Create_Mag (mag &, int &);
void Search_Mag (const mag, int);
void Delete_mag (mag &, int);
codice:
void Create_Mag (mag & v, int & n) {
cout<<"\n Numero di prodotti da inserire: ";
cin>>n;
v= new prod [n];
for (int i=0;i<n;i++){
cout<<"\n Prodotto "<<i;
Insert_Prod (v[i]);
}
}
Poi questo è il main che ho fatto, è ovviamente temporaneo giusto per controllare che l'allocazione del vettore riesca.
codice:
#include "magazzino.h"
int main () {
mag v;
int n;
Create_Mag(v,n);
return 0;
}
Come dicevo prima il programma arriva a farmi inserire il codice prodotto del primo elemento, dopodichè va in tilt e compaiono queste scritte
codice:
[Session started at 2010-11-14 14:34:02 +0100.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct 2 04:07:49 UTC 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/adry_cast/Desktop/Progetti C++/Magazzino_dinamico/build/Debug/Magazzino_dinamico', process 1206.
warning: Could not find malloc init callback function.
Make sure malloc is initialized before calling functions.
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
unable to read unknown load command 0x80000022
(gdb)
La prossima volta posto tutto dall'inizio
Originariamente inviato da MacApp
Dev-C++ è obsoleto, Xcode è ottimo.
Se vuoi capire meglio cosa avviene "sotto", non escludere di provare a compilare direttamente da linea di comando utilizzando gcc/g++.
Immaginavo che fosse un pò obsoletuccio...
Per quel che riguarda il capire meglio, in realtà io con il dev-c++ mi faccio anche il makefile però con xcode ancora non ho provato...