Scusate, ho scordato di mettere l'IDE: Embedded Visual C++.
Vi posto anche i file, tanto sono piccoli.
codice:
#define MAX_LENGHT 50
class LetturaFW {
private:
char *modelloPalmare[MAX_LENGHT]; // mi dice il modello del palmare es. AT420
char *siglaPalmare[MAX_LENGHT]; // mi dice la sigla associate al modello del palmare es. AP4
public:
LetturaFW(char *nomeFile); // costruttore
~LetturaFW(); // distruttore
char *getModelByFW(char *nomeModello); // mi legge il file di testo e mi salva i dati negli array
};
codice:
#include "LetturaFW.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
// costruttore
LetturaFW::LetturaFW(char *nomeFile){
FILE *fp; // file pointer
char c;
char *array, *modello, *sigla, *temp;
int i=0, j, indice=0;int stringa=0;
bool flag = true;
for(i=0; i<MAX_LENGHT; i++)
{
modelloPalmare[i] = (char *)malloc(MAX_LENGHT);
siglaPalmare[i] = (char *)malloc(MAX_LENGHT);
}
array = (char*) malloc (MAX_LENGHT*2);
temp = (char*) malloc (MAX_LENGHT*2);
modello = (char*) malloc (MAX_LENGHT);
sigla = (char*) malloc (MAX_LENGHT);
fp = fopen(nomeFile, "r");
if(fp == NULL){
printf("Errore: controllare il path del file\n");
exit(0);
}
do
{
fgets(array, MAX_LENGHT*2, fp);
if(array[0] != '[' && array[0] != '#')
{
for (j=0, i=0; array[i] != '='; j++, i++)
{
modello[j] = array[i];
}
modello[j] = '\0'; // termino l'array
i++;
for (j=0; array[i] != '\n'; j++, i++)
{
sigla[j] = array[i];
}
sigla[j] = '\0'; // termino l'array
strcpy(modelloPalmare[indice], modello);
strcpy(siglaPalmare[indice], sigla);
indice++;
} // end IF
if(strcmp(temp, array) == 0)
flag = false;
strcpy(temp, array);
} while (flag == true);
fclose(fp);
}
// distruttore
LetturaFW::~LetturaFW(){
}
// altri metodi
char *LetturaFW::getModelByFW(char *nomeFW){
int i=0;
while (strcmp(nomeFW, modelloPalmare[i]) != 0 )
i++;
return siglaPalmare[i];
} // fine metodo getModelByFW()
E qui gli errori
codice:
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(9) : error C2653: 'LetturaFW' : is not a class or namespace name
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(16) : error C2065: 'MAX_LENGHT' : undeclared identifier
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(18) : error C2065: 'modelloPalmare' : undeclared identifier
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(18) : error C2109: subscript requires array or pointer type
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(19) : error C2065: 'siglaPalmare' : undeclared identifier
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(19) : error C2109: subscript requires array or pointer type
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(48) : error C2109: subscript requires array or pointer type
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(48) : error C2664: 'strcpy' : cannot convert parameter 1 from 'int' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(49) : error C2109: subscript requires array or pointer type
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(49) : error C2664: 'strcpy' : cannot convert parameter 1 from 'int' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(60) : error C2653: 'LetturaFW' : is not a class or namespace name
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(65) : error C2653: 'LetturaFW' : is not a class or namespace name
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(68) : error C2109: subscript requires array or pointer type
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(68) : error C2664: 'strcmp' : cannot convert parameter 2 from 'int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\CIGE Mobile\rel 3.0\dev\client\ApplicazioneCIGE\Cige\LetturaFW.cpp(68) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Grasssie