Top Qs
Chronologie
Chat
Contexte
Indent
programme de formatage de code source De Wikipédia, l'encyclopédie libre
Remove ads
indent est un logiciel libre de mise en forme de codes sources en langage C. Il modifie l'apparence d'un fichier source en ajoutant ou supprimant des espaces et des retours à la ligne.
indent fait partie du projet GNU, Il est distribué selon les termes de la licence GNU GPL.
Remove ads
Exemple
On souhaite indenter le fichier suivant :
/* exemple à indenter */
#include <stdio.h>
int main(void)
{
char msg[] = "hello world\n";
char * end = msg + sizeof (msg);
char * cur;
for(cur = msg; cur != end; ++cur) { putchar(*cur); }
return 0;
}
Avec les paramètres par défaut, on obtient le style GNU:
#include <stdio.h>
int
main (void)
{
char msg[] = "hello world\n";
char *end = msg + sizeof (msg);
char *cur;
for (cur = msg; cur != end; ++cur)
{
putchar (*cur);
}
return 0;
}
Avec l'option -kr (pour "Kernighan and Ritchie"), on obtient :
#include <stdio.h>
int main(void)
{
char msg[] = "hello world\n";
char *end = msg + sizeof(msg);
char *cur;
for (cur = msg; cur != end; ++cur) {
putchar(*cur);
}
return 0;
}
Remove ads
Voir aussi
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads