Supportnet / Forum / Anwendungen(Java,C++...)
C Problem mit Funktion
Frage
[code]
char *freadline (FILE *fp)
{
static char *line = NULL;
static size_t line_size = 1024;
char *cp;
size_t rest_size;
if(!line) line=malloc(line_size);
cp = line;
rest_size = line_size;
while(fgets(cp,rest_size,fp), !ferror(fp) && strlen(cp)>0 && cp[strlen(cp)-2]!=´\n´ && !feof(fp))
{
line_size+=1024;
realloc(line,line_size);
rest_size = line_size-strlen(line);
cp = line+strlen(line);
}
return (ferror(fp) || !line[0] ? NULL : line);
}
int main(int argc, char **argv) {
//Nur als Beispiel!
char ch = NULL;
char line[1024 + 1];
FILE* stream = (FILE*)NULL;
stream = fopen( "test.txt", "rt" );
if( stream == NULL)
return -1;
// while( !feof(stream) ){
printf("%s \n", freadline(stream));
// }
fclose( stream );
return 1;
}
[/code]
also der Code funktioniert nicht, da bekomme ich STATUS_ACCESS_VIOLATION...
hat jemand eine Idee?

