Code
De Wikip
Version : 1.36.1 773 (2013-12-5) 20131205081104
Auteurs :
Arthur Torossian
Résumé :
Ce modèle sert présenter un code programmation.
{{code|lang=|code=}}
- lang=
- c++ php …
- code=
- le code
Exemple :
{{code|lang=cpp|code=
#include <time.h>
#include <stdio.h>
void sleep( time_t nb_sec )
{
time_t limit, top;
time(&top);
limit = top + nb_sec ;
while (top < limit)
{
time(&top);
}
};
int main( int argc, char * argv[] )
{
time_t start, stop;
time(&start);
sleep( 5 ) ;
time(&stop);
printf("start : %ld\n",start );
printf("stop : %ld\n",stop );
printf("in seconds: %f\n",difftime(stop,start));
}
}}
donnera :
#include <time.h>
#include <stdio.h>
void sleep( time_t nb_sec )
{
time_t limit, top;
time(&top);
limit = top + nb_sec ;
while (top < limit)
{
time(&top);
}
};
int main( int argc, char * argv[] )
{
time_t start, stop;
time(&start);
sleep( 5 ) ;
time(&stop);
printf("start : %ld\n",start );
printf("stop : %ld\n",stop );
printf("in seconds: %f\n",difftime(stop,start));
}