Se potessi volentieri, ti farei compagnia...
Speriamo che riesca a hackerare qualche DB bancario cosė invece del biglietto ti regalo la casa...
CC,
BB.....![]()
Se potessi volentieri, ti farei compagnia...
Speriamo che riesca a hackerare qualche DB bancario cosė invece del biglietto ti regalo la casa...
CC,
BB.....![]()
Purtroppo devo ancora scassarti....
Se questo codice dovessi metterlo all'interno di una funzione e farmi restituire l'array come potrei fare?
codice:char string[] = "From: JACOPO \r\n X-Mailer: WeB \r\n"; char seps[] = "\r\n"; char *token; char *dest[255]; int counter,i; printf( "%s\n\nTokens:\n", string ); token = strtok( string, seps ); counter = 0; while( token != NULL ) { dest[counter] = token; //array che mi serve printf( "%s\n", token ); token = strtok( NULL, seps ); counter++; }![]()
![]()
![]()
![]()
![]()
*char[] getMaCheNeSo(char *string) {
// code
return dest;
}
Quindi dovrei scrivere una cosa di questo tipo ???
*char[] log_header(char *string)
{
char seps[] = "\r\n";
char *token;
char *dest[255];
int counter;
token = strtok( string, seps );
counter = 0;
while( token != NULL )
{
dest[counter] = token;
token = strtok( NULL, seps );
counter++;
}
return dest;
}
credo
ma dato che non scrivo in C da un sacco di tempo![]()
Hai idea del perchč il compilatore gcc mi restituisca un errore del tipo : "Segmentation fault" ?
ho provato con questo
compila e viene eseguito, il fatto č che il valore di ritorno č buffocodice:char** tokenizza(const char *stringa) { char *s = strchr(stringa, '\n'); char *str1; int numeroDiToken = 1; while (s != NULL) { numeroDiToken++; s = strchr(s+1, '\n'); } char *dest[numeroDiToken]; int c = 0; // primo token str1 = strtok(stringa, "\n"); if (str1 != NULL) { dest[c++] = str1; } while (1) { // successivo token str1 = strtok(NULL, "\n"); if (str1 == NULL) { printf("Tokenizing complete\n"); break; } dest[c++] = str1; } return dest; }
dentro la funzione se scrivo dest[c] quando gli assegno la stringa mi mostra quello che voglio, fuori dalla funz fa casino![]()