Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1

    [C] Dimensione di un file

    Salve a todos ^^

    dunque sto scrivendo 1 programmino 1 po particolare che ha bisogno di prendere tutto il file e metterlo in memoria e poi sopra a questo eseguire delle operazioni

    devo ovviamente usare malloc\free per lo spazio dove salvare il file

    pensavo di fare una cosa del tipo...
    -apro il file
    -con fseek mi sposto alla fine del file
    -imposto la memoria basandomi sul risultato di fseek
    -con fseek mi riposiziono all'inizio

    xo ... siccome non so se ci sono vie + veloce...volevo sapere se ne conoscevate

  2. #2

  3. #3
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    yes (syscall).
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

  4. #4
    :\

    mi ritorna false :\

    nel senso che se faccio

    codice:
    if (!stat(....)) {
      ...
    }
    mi va dentro l'if :\

  5. #5
    ok sono faggiano

    dovevo fare < 0

  6. #6
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    stat ritorna zero se non ci sono stati errori
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

  7. #7
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    ritorna -1 se invece si è verificato qualche problema
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

  8. #8
    Utente bannato
    Registrato dal
    Sep 2003
    Messaggi
    1,012
    Cos'è questa stat?
    Una funzione standard?
    Se sì, che .h devo includere?
    Se no, come la implemento?


  9. #9
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    stat è una chiamata di sistema inclusa nello standard POSIX.
    (ci sono anche lstat e fstat)

    per linux:
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

  10. #10
    Originariamente inviato da iguana13
    Cos'è questa stat?
    Una funzione standard?
    Se sì, che .h devo includere?
    Se no, come la implemento?

    credo sia standard xche l'ho trovata su un forum che trattava msvc6 quindi ^^

    sys/stat.h
    sys/types.h

    credo che bastino

    ti riempe una struttura...solo che nn so quali elementi contiene a parte st_size che è l'unico che mi interessava

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 © 2024 vBulletin Solutions, Inc. All rights reserved.