Je ne dispose pas de la fonction strtok (c'est un vieux compilateur...)
Quelqu'un aurait-il le code de cette fonction (si possible en s'appuyant sur des fonctions esistantes de string.h) ?
Sinon je recode bien sur...
Je ne dispose pas de la fonction strtok (c'est un vieux compilateur...)
Quelqu'un aurait-il le code de cette fonction (si possible en s'appuyant sur des fonctions esistantes de string.h) ?
Sinon je recode bien sur...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 char * strtok(char *s, const char *delim) { const char *spanp; int c, sc; char *tok; static char *last; if (s == NULL && (s = last) == NULL) return (NULL); /* * Skip (span) leading delimiters (s += strspn(s, delim), sort of). */ cont: c = *s++; for (spanp = delim; (sc = *spanp++) != 0;) { if (c == sc) goto cont; } if (c == 0) { /* no non-delimiter characters */ last = NULL; return (NULL); } tok = s - 1; /* * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). * Note that delim must have one NUL; we stop if we see that, too. */ for (;;) { c = *s++; spanp = delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; last = s; return (tok); } } while (sc != 0); } /* NOTREACHED */ }
Heu, j'ai ajouté:
par contre, olds, cela sort d'où ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part # define __rawmemchr strchr
Finalement, j'ai trouvé sur le net
Merci et bon Dimanche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 static char *strtok_pos; char * strtok_r(char *ptr, const char *sep, char **end) { if (!ptr) /* we got NULL input so then we get our last position instead */ ptr = *end; /* pass all letters that are including in the separator string */ while (*ptr && strchr(sep, *ptr)) ++ptr; if (*ptr) { /* so this is where the next piece of string starts */ char *start = ptr; /* set the end pointer to the first byte after the start */ *end = start + 1; /* scan through the string to find where it ends, it ends on a null byte or a character that exists in the separator string */ while (**end && !strchr(sep, **end)) ++*end; if (**end) { /* the end is not a null byte */ **end = '\0'; /* zero terminate it! */ ++*end; /* advance last pointer to beyond the null byte */ } return start; /* return the position where the string starts */ } /* we ended up on a null byte, there are no more strings to find! */ return NULL; } char *strtok(char *s, const char *delim) { return strtok_r(s,delim,&strtok_pos); }
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager