1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char FileName[] = "C:\\Mes Documents\\developpez.c";
size_t taille = sizeof(FileName) + strlen("notepad ");
char * chaineInterpretable = malloc( taille );
//int snprintf (char *str, size_t size, const char *format, ...);
snprintf(chaineInterpretable, taille, "notepad %s", FileName );
printf("Taille allouee : %d\n"
"Chaine obtenue = [%s]\n\n", taille, chaineInterpretable);
system(chaineInterpretable);
free(chaineInterpretable); // par acquis de conscience
return 0;
} |