Torna indietro   Hardware Upgrade Forum > Software > Programmazione

HONOR Magic 8 Pro: ecco il primo TOP del 2026! La recensione
HONOR Magic 8 Pro: ecco il primo TOP del 2026! La recensione
HONOR ha finalmente lanciato il suo nuovo flagship: Magic 8 Pro. Lo abbiamo provato a fondo in queste settimane e ve lo raccontiamo nella nostra recensione completa. HONOR rimane fedele alle linee della versione precedente, aggiungendo però un nuovo tasto dedicato all'AI. Ma è al suo interno che c'è la vera rivoluzione grazie al nuovo Snapdragon 8 Elite Gen 5 e alla nuova MagicOS 10
Insta360 Link 2 Pro e 2C Pro: le webcam 4K che ti seguono, anche con gimbal integrata
Insta360 Link 2 Pro e 2C Pro: le webcam 4K che ti seguono, anche con gimbal integrata
Le webcam Insta360 Link 2 Pro e Link 2C Pro sono una proposta di fascia alta per chi cerca qualità 4K e tracciamento automatico del soggetto senza ricorrere a configurazioni complesse. Entrambi i modelli condividono sensore, ottiche e funzionalità audio avanzate, differenziandosi per il sistema di tracciamento: gimbal a due assi sul modello Link 2 Pro, soluzione digitale sul 2C Pro
Motorola edge 70: lo smartphone ultrasottile che non rinuncia a batteria e concretezza
Motorola edge 70: lo smartphone ultrasottile che non rinuncia a batteria e concretezza
Motorola edge 70 porta il concetto di smartphone ultrasottile su un terreno più concreto e accessibile: abbina uno spessore sotto i 6 mm a una batteria di capacità relativamente elevata, un display pOLED da 6,7 pollici e un comparto fotografico triplo da 50 MP. Non punta ai record di potenza, ma si configura come alternativa più pragmatica rispetto ai modelli sottili più costosi di Samsung e Apple
Tutti gli articoli Tutte le news

Vai al Forum
Discussione Chiusa
 
Strumenti
Old 12-04-2008, 18:28   #1
_=<ne0h>=_
Junior Member
 
Iscritto dal: Apr 2008
Messaggi: 9
Problema con visualizzazione file di testo!

Scusate,
ho questa funzione per visualizzare un file di testo:
Codice:
#define CR 13            /* Decimal code of Carriage Return char */
#define LF 10            /* Decimal code of Line Feed char */
#define EOF_MARKER 26    /* Decimal code of DOS end-of-file marker */
#define MAX_REC_LEN 1024 /* Maximum size of input buffer */
#define MAX_NUM_LINE 32
#define MAX_LINE_LENGTH 30

int T_fgetc(FILE *input, char *output){
  int  iReturn   = 1;  /* Return value (Innocent until proved guilty) */
  int  iThisChar;      /* Current character */
  int  isNewline = 0;  /* Boolean indicating we've read a CR or LF */
  long lIndex    = 0L; /* Index into read buffer */

  while (1) /* Will exit on error, end of line, or end of file */
  {
    iThisChar = fgetc(input);     /* Read the next character */

    if (ferror(input))            /* Error reading */
    {
      iReturn = -1;           /* Convert to negative number */
      break;
    }

    if (iThisChar == EOF)         /* End of file reached */
    {
 
      if (lIndex > 0)
        ungetc(iThisChar, input);

      else           /* Nothing read but EOF; we're done with the file */
        iReturn = 0;

      break;
    }

    if (!isNewline) /* Haven't read a CR or LF yet */
    {
      if (iThisChar == CR || iThisChar == LF) /* This char IS a CR or LF */
        isNewline = 1;                        /* Set flag */
    }

    else            /* We've already read one or more CRs or LFs */
    {
      if (iThisChar != CR && iThisChar != LF) /* This char is NOT a CR or LF */
      {
        ungetc(iThisChar, input);             /* Put char back in stream */
        break;                                /* Done reading this line */
      }
    }

    output[lIndex++] = iThisChar;             /* Put char in read buffer */

  } /* end while (1) */

  output[lIndex] = '\0';                      /* Terminate the read buffer */
  return iReturn;

} /* end T_fgetc() */

void PrintLine(char *szReadLine,  long lLineCount, long lLineLen, long lThisFilePos, long *lLastFilePos, int  isFilePosErr){
  char *cPtr;
  cPtr = szReadLine;
  for (cPtr = szReadLine; cPtr <= szReadLine + lLineLen; cPtr++)
  {
            switch (*cPtr)
            {
             case 0:          /* Null terminator */
                  break;
             case CR:                /* Carriage return */
                  break;
             case LF:                /* Line feed */
                  printf("\n");
                  break;
             default:                /* A 'real' character */
                  printf("%c", *cPtr);
                  break;
             }
  }
  printf("\n");
  return;

}

int Reader(char* filen, int linestart)
{
  int (*GetLine[1])(FILE*, char*) = { T_fgetc };
  char tmode[5];
  int   iReadMode=0;             /* Index into *GetLine[] array */
  int   iReadReturn;             /* Result of read function */
  int   isFilePosErr;            /* Boolean indicating file offset error */
  long  lFileLen;                /* Length of file */
  long  lLastFilePos;            /* Byte offset of end of previous line */
  long  lLineCount;              /* Line count accumulator */
  long  lLineLen;                /* Length of current line */
  long  lThisFilePos;            /* Byte offset of start of current line */
  char  szReadLine[MAX_REC_LEN];
  FILE *inputFilePtr;            /* Pointer to input file */

  strcpy(tmode, "t");

  if (strcmp(tmode, "t") == 0)
    inputFilePtr = fopen(filen, "r");  /* Open in TEXT mode */

  else if (strcmp(tmode, "b") == 0)
    inputFilePtr = fopen(filen, "rb"); /* Open in BINARY mode */

  if (inputFilePtr == NULL )             /* Could not open file */
  {
    printf("Error opening %s\n", filen);
    return 1;
  }
  
  fseek(inputFilePtr, 0L, SEEK_END);     /* Position to end of file */
  lFileLen = ftell(inputFilePtr);        /* Get file length */
  rewind(inputFilePtr);                  /* Back to start of file */
  
  lLineCount   =  0L; /* No lines read yet */
  lLastFilePos = -1L; /* So first line doesn't show an offset error */
  
  cls();
  while (1)
  {
    isFilePosErr = 0;
    lThisFilePos = ftell(inputFilePtr);
    if (lThisFilePos != lLastFilePos + 1){
                     isFilePosErr = 1;
                     }
      szReadLine[0] = '\0';

    /* Read the next line with the appropriate read function */
    iReadReturn = (*GetLine[iReadMode])(inputFilePtr, szReadLine);

    if (iReadReturn < 0)
    {
      printf("Error reading: %s\n", filen);
      break;
    }
    lLineLen = strlen(szReadLine); /* Get length of line */
    if (lLineLen)                  /* Got some data */
    {
      ++lLineCount;                /* Increment line counter */
    }
    
    if(lLineCount>=linestart && lLineCount<(linestart+MAX_NUM_LINE)){
                 PrintLine(szReadLine, lLineCount, lLineLen, lThisFilePos, &lLastFilePos, isFilePosErr);
    }
    if (iReadReturn == 0)          /* End of file reached */
       break;
  }
  fclose(inputFilePtr); /* Close the file */
  return 0;
}
Il problema è che devo poter scorrere il testo e non posso usare delle API, con la funzione Reader dovrei passare il nome del file e la linea di partenza per la visualizzazione sullo schermo, ed essa aumenta e diminuisce quando premo rispettivamente giu e su!, solo che quando avvio questa funzione mi viene fuori un bel casino, dato che se la stringa è più lunga della finestra me la manda a capo e la conta come un'altra linea!
Qualcuno può darmi una aiuto?
_=<ne0h>=_ è offline  
Old 15-04-2008, 00:51   #2
cionci
Senior Member
 
L'Avatar di cionci
 
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
Thread chiuso
|
V
cionci è offline  
 Discussione Chiusa


HONOR Magic 8 Pro: ecco il primo TOP del 2026! La recensione HONOR Magic 8 Pro: ecco il primo TOP del 2026! L...
Insta360 Link 2 Pro e 2C Pro: le webcam 4K che ti seguono, anche con gimbal integrata Insta360 Link 2 Pro e 2C Pro: le webcam 4K che t...
Motorola edge 70: lo smartphone ultrasottile che non rinuncia a batteria e concretezza Motorola edge 70: lo smartphone ultrasottile che...
Display, mini PC, periferiche e networking: le novità ASUS al CES 2026 Display, mini PC, periferiche e networking: le n...
Le novità ASUS per il 2026 nel settore dei PC desktop Le novità ASUS per il 2026 nel settore de...
StackWarp: una nuova vulnerabilità...
Il telescopio spaziale James Webb ha cat...
Il razzo spaziale europeo Ariane 6 lance...
Il lander lunare Blue Origin Blue Moon M...
Gli LLM riescono a risolvere problemi ma...
Smettila con quei cioccolatini. Per San ...
Il secondo lancio del razzo spaziale eur...
MaiaSpace ed Eutelsat stringono un accor...
Motorola edge 60 neo sorprende: compatto...
Zeekr 007 e 007GT si aggiornano: piattaf...
ASUS ROG Swift OLED PG27AQWP-W: 720 Hz e...
È super il prezzo del robot rasae...
MediaTek aggiorna la gamma di Dimensity:...
Foto intime sottratte dai telefoni in ri...
In Cina approvate nuove regole per il ri...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 08:35.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v