Ich habe einige Probleme mit dem Lesen von Dateien mit C++ mit stdlib.h-Header. Bitte korrigieren Sie die Fehler in meiner Syntax. Der Compiler sagte 'FILE hat kein Mitglied namens Puffer, Curp, Fd und Flags' Was bedeutet das?Lesen von Dateien mit stdlib.h C++
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *fp;
if ((fp = fopen("text.txt", "w"))==NULL){
printf("error!");
exit(1);
}
fputs("ABCDE\n", fp);
printf("file address : %p\n", fp->buffer);
printf("file size : %d byte \n", fp->bsize);
printf("file position : %p\n", fp->curp);
printf("file contents : ");
for (int i = 0; i <= 4; i++){
printf("%c", *(fp->buffer+i));
}
printf("\n");
printf("file identity is unknown : %d\n", fp->fd);
printf("file status : \n");
if ((fp->flags & 1)==1) printf ("readonly\n");
if ((fp->flags & 2)==2) printf ("writeonly\n");
if ((fp->flags & 3)==3) printf ("read/write\n");
if ((fp->flags & 8)==8) printf ("file line\n");
if ((fp->flags & 16)==16) printf ("error\n");
if ((fp->flags & 32)==32) printf ("end of the file\n");
if ((fp->flags & 64)==64) printf ("binary file\n"); else printf ("file text\n");
if ((fp->flags & 128)==128) printf ("data from file\n");
if ((fp->flags & 256)==256) printf ("data from file\n");
if ((fp->flags & 512)==512) printf ("file is in the terminal\n"); else printf("file is in the disk");
fclose(fp);
}
Fehlermeldungen wörtlich bitte! –
Was meinst du? –
_ "'DATEI hat kein Mitglied benannt ...'" _ Bitte geben Sie den vollständigen Wortlaut bitte an! (in deiner Frage) –