Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di Ed_Bunker
    Registrato dal
    Jul 2003
    Messaggi
    1,119

    [C] Ricercare una sottostriga...

    Ciao, dovrei implementare una funzione che ricerchi (data una sottostringa ed il nome di un file .txt ) la sottostringa all'interno di tale file restituendo la posizione in cui si trova (La prima occorrenza) o -1 se la sottostringa non e' stata trovata. Avete suggerimenti, link o qualche algoritmo che renda abbastanza efficiente tale operazione ?!?

    thks

  2. #2
    In String.h esiste la funzione strstr();

    codice:
    Syntax:
    
      #include <string.h>
      char *strstr( const char *str1, const char *str2 );
    
    The function strstr() returns a pointer to the first occurrence of str2 in str1, or NULL if no match is found.
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  3. #3
    Utente di HTML.it L'avatar di Ed_Bunker
    Registrato dal
    Jul 2003
    Messaggi
    1,119
    Originariamente inviato da kNemo
    In String.h esiste la funzione strstr();

    codice:
    Syntax:
    
      #include <string.h>
      char *strstr( const char *str1, const char *str2 );
    
    The function strstr() returns a pointer to the first occurrence of str2 in str1, or NULL if no match is found.
    thks !!

  4. #4
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  5. #5
    Utente di HTML.it L'avatar di Ed_Bunker
    Registrato dal
    Jul 2003
    Messaggi
    1,119
    Originariamente inviato da kNemo
    www.cppreference.com

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.