Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di freetom
    Registrato dal
    Nov 2001
    Messaggi
    3,725

    [c++] eof non definito...

    Ho questo cod:

    #include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {

    //SPAZIO PER LETTURA FILE...

    FILE * pFile;
    char string [1000];

    pFile = fopen ("estrazioni.txt" , "r");
    if (pFile == NULL) perror ("Errore");

    else {
    while(!pFile.eof()) {
    fgets(string , 100 , pFile);
    puts (string);
    }
    }


    //--------------------------


    cout << "Press ENTER to continue..." << endl;
    cin.get();
    return 0;

    }



    che mi da questo errore in fase di compilazione:

    errore:
    17 C:\Dev-Cpp\leggererigaxriga2.cpp `eof' has not been declared

    Come potrei risolvere?


  2. #2
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    Stai confondendo C e C++.
    Corretto è:
    codice:
    while(!feof(pFile))
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  3. #3
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    pFile e' un puntatore a FILE, non un oggetto ... (fopen e' C e non C++).

    Per l'eof devi usare la funzione corrispondente

    feof()
    No MP tecnici (non rispondo nemmeno!), usa il forum.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.