ciao,
come faccio a dividere in C una stringa in base al carattere "." ?
Vorrei avere un vettore vettore di 4 posizioni contenente:codice:esempio: char stringa[]="ciao.roberto.come.va";
graziecodice:ciao roberto come va
ciao,
come faccio a dividere in C una stringa in base al carattere "." ?
Vorrei avere un vettore vettore di 4 posizioni contenente:codice:esempio: char stringa[]="ciao.roberto.come.va";
graziecodice:ciao roberto come va
Un vettore di 4 posizioni....
Ti piacciono i puntatori?
codice:char str[] = "ciao.roberto.come.va"; char *i = str; char **moreStr = NULL; int nDot = 0; while( *i++ != '\0' ) { if( *i == '.' ) ++nDot; } moreStr = (char **) malloc( (nDot+1) * sizeof(char *) ); if( moreStr != NULL ) { int pos = 0; i = str; moreStr[ pos++ ] = i; while( *i++ != '\0' ) { if( *i == '.' ) { *i = '\0'; moreStr[ pos++ ] = ++i; } } stampa( moreStr, nDot+1 ); // FAI QUELLO CHE VUOI.... free( moreStr ); }
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.
grazie mille!!! sei il mio nuovo idolo!!! non sai quante parole ho tirato fino ad ora!!
grazie grazie grazie!
Figurati
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.