"debut TD0"

This commit is contained in:
JunkJumper 2020-09-04 10:27:13 +02:00
parent ac93b9b2af
commit cf00c53e65
88 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "util_afficher.h"
int main (int argc, char * argv[], char * envp[])
{
if (argc != 2) {fprintf (stderr, "\nSyntaxe : %s <chaine> \n\n", argv[0]); exit (1); }
afficher_chaine(argv[1]);
}

View File

@ -0,0 +1,9 @@
/*********************************/
/* Specification afficher_chaine */
/*********************************/
#include <stdio.h>
#include "util_afficher.h"
void afficher_chaine (char * chaine) {
printf ("\n\n*** %s ! ***\n\n", chaine);
}

View File

@ -0,0 +1,5 @@
/*********************************/
/* Specification afficher_chaine */
/*********************************/
void afficher_chaine (char * chaine);

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char * argv[], char * envp[])
{
FILE *leFichier ;
int n;
// assert (argc == 2);
if (argc != 2) {fprintf (stderr, "\nSyntaxe : %s <chaine> \n\n", argv[0]); exit (1); }
leFichier = fopen (argv[1], "w");
n = fwrite ("OK !\13\10\10\10\10", strlen ("OK !\13\10\10\10\10"), 1, leFichier);
fclose ( leFichier);
printf ("\nhello %s\n\n", argc);
printf ("\n\n\n Fin normale du programme\n\n");
}

View File

@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int main (int argc, char * argv[], char * envp[])
{
assert (argc == 2);
//if (argc != 2) {fprintf (stderr, "\nSyntaxe : %s <chaine> \n\n", argv[0]); exit (1); }
printf ("\nhello %s\n\n", argv[1]);
}

View File

@ -0,0 +1,15 @@
/*
gcc processus_1.c
Exemple : ./a.out un deux trois
*/
#include <stdio.h>
#include <unistd.h>
int main(int argc, char * argv[]){
int i;
for (i=1; i< argc; i++) {
printf("argument %d: %s\n",i,argv[i]);
}
printf("\nPID = %d - PPID = %d \n\n",getpid(), getppid());
return 0;
}

View File

@ -0,0 +1,18 @@
/*
gcc processus_2.c
Exemple : ./a.out PATH
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{
fprintf (stderr, "Syntaxe : %s <nom-de-variable>\n", argv[0]);
exit (1);
}
printf ("\n%s\n\n", getenv (argv[1]));
return EXIT_SUCCESS;
}