On Feb 1, 6:53 am, Vincent Lefevre <vincent+ wrote:
Dans l'article <47a1fe23$0$12987$, Antoine Leca écrit:
#include <string.h> #include <stdlib.h> #include "strlcpy.h" /*size_t strlcpy(char *dst, const char *src, size_t siz);*/ char* strsub(const char chaîne[], unsigned début, unsigned fin) { size_t alloué; char *r; if( début>strlen(chaîne) || fin<début || !(r = malloc(alloué = fin-début+1)) ) return NULL; strlcpy(r, chaîne+début, alloué); return r; } S'il vous manque strlcpy sur votre machine, ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c (et récupérez donc en même temps ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c, et jette z donc un oeil distrait à l'indicatif utilisateur de la dernière perso nne ayant modifié ce source... ;-) )
Et récupérez un compilateur qui reconnaisse les caractères accentu és. :)
-- Vincent Lefèvre - Web: <http://www.vinc17.org/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/> Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)- H ide quoted text -
- Show quoted text -
J'allais le dire. . .
On Feb 1, 6:53 am, Vincent Lefevre <vincent+n...@vinc17.org> wrote:
Dans l'article <47a1fe23$0$12987$426a7...@news.free.fr>,
Antoine Leca <r...@localhost.invalid> écrit:
#include <string.h>
#include <stdlib.h>
#include "strlcpy.h"
/*size_t strlcpy(char *dst, const char *src, size_t siz);*/
char* strsub(const char chaîne[], unsigned début, unsigned fin)
{
size_t alloué;
char *r;
if( début>strlen(chaîne)
|| fin<début
|| !(r = malloc(alloué = fin-début+1)) )
return NULL;
strlcpy(r, chaîne+début, alloué);
return r;
}
S'il vous manque strlcpy sur votre machine,
ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c
(et récupérez donc en même temps
ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c, et jette z
donc un oeil distrait à l'indicatif utilisateur de la dernière perso nne ayant
modifié ce source... ;-) )
Et récupérez un compilateur qui reconnaisse les caractères accentu és. :)
--
Vincent Lefèvre <vinc...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)- H ide quoted text -
On Feb 1, 6:53 am, Vincent Lefevre <vincent+ wrote:
Dans l'article <47a1fe23$0$12987$, Antoine Leca écrit:
#include <string.h> #include <stdlib.h> #include "strlcpy.h" /*size_t strlcpy(char *dst, const char *src, size_t siz);*/ char* strsub(const char chaîne[], unsigned début, unsigned fin) { size_t alloué; char *r; if( début>strlen(chaîne) || fin<début || !(r = malloc(alloué = fin-début+1)) ) return NULL; strlcpy(r, chaîne+début, alloué); return r; } S'il vous manque strlcpy sur votre machine, ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c (et récupérez donc en même temps ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c, et jette z donc un oeil distrait à l'indicatif utilisateur de la dernière perso nne ayant modifié ce source... ;-) )
Et récupérez un compilateur qui reconnaisse les caractères accentu és. :)
-- Vincent Lefèvre - Web: <http://www.vinc17.org/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/> Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)- H ide quoted text -