Salve ragazzi ho un piccolo problema non riesco a leggere il contenuto di un file..
mi spiego meglio utilizzo i lseguente codice:
[code]
LISTAFILE *CreaLista(char * nomeFile, LISTAFILE *pListaFile)
{
LISTAFILE *pAux=NULL;
char * buffer=NULL;
FILE *fp;
fp=fopen(nomeFile,"r");
if (fp!=NULL)
{
while (feof(fp)==0)
{
fscanf(fp,"%s",&buffer);
if (pListaFile==NULL)
{
pListaFile=(LISTAFILE*)malloc(sizeof (LISTAFILE));
pListaFile->nomeColore= (char *) malloc(&strlen(buffer));
strcpy(pListaFile->nomeColore,&buffer);
pListaFile->pNext=NULL;
}
else
{
LISTAFILE *pUltimo;
pAux=(LISTAFILE * ) malloc (sizeof (LISTAFILE));
pAux->nomeColore=(char *) malloc(strlen(&buffer));
strcpy(pAux->nomeColore,&buffer);
pUltimo=CercaFine(pListaFile);
pAux->pNext=NULL;
pUltimo->pNext=pAux;
}
}
fclose(fp);
}
return pListaFile;
}
[\code]
e fin qui nessun problema, il problema si verifica con i warning che mi vengono restituiti:
Compiling...
prova.c
D:\prova.c(558) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'char ** '
D:\prova.c(558) : warning C4024: 'strlen' : different types for formal and actual parameter 1
D:\prova.c(559) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'char ** '
D:\prova.c(559) : warning C4024: 'strcpy' : different types for formal and actual parameter 2
D:\prova.c(572) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'char ** '
D:\prova.c(572) : warning C4024: 'strlen' : different types for formal and actual parameter 1
D:\prova.c(573) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'char ** '
D:\prova.c(573) : warning C4024: 'strcpy' : different types for formal and actual parameter 2
prova.obj - 0 error(s), 8 warning(s)
la struttura di LISTAFILE è :
typedef
struct listaFile
{
char * nomeColore;
struct listaFile *pNext;
}LISTAFILE;
Qualcuno può aiutarmi???