slt svp j'ai besoin d'aide j'ai un code a realiser et j'ai besoin d'aide pour commencer si quelq'un peu m'aider a le realiser ca concerne un gestion de menu en utilisant le langege c svp aider moi
slt svp j'ai besoin d'aide j'ai un code a realiser et j'ai besoin d'aide pour commencer si quelq'un peu m'aider a le realiser ca concerne un gestion de menu en utilisant le langege c svp aider moi
Salut,
Un menu ?
C'est pour un projet console ou via une interface graphique ?
Si c'est pour console, on peut faire comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 #include <stdio.h> #include <stdlib.h> int main(void) { int fin; fin = 0; while(!fin) { int c; /* affichage menu */ printf("1.Choix 1\n" "2.Choix 2\n" "3.Choix 3\n" "4.Quitter\n"); c = getchar(); /* suppression des caracteres dans stdin */ if(c != '\n' && c != EOF) { int d; while((d = getchar()) != '\n' && d != EOF); } switch(c) { case '1': printf("Choix 1\n"); break; case '2': printf("Choix 2\n"); break; case '3': printf("Choix 3\n"); break; case '4': fin = 1; break; default: printf("Choix errone\n"); } } return 0; }
Vois du côté de ncurses pour créer de jolies UI en mode texte
http://www.gnu.org/software/ncurses/
tu peux aussi faire un menu avec "selection"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 #include<conio.h> main() { int i,choix; char menu[4][15]={"start","action","end"}; int nombre=0; clrscr(); do{ for(i=0;i<3;i++) { gotoxy(10,5+i); if (i==nombre) { textcolor(WHITE); textbackground(BLACK); } cprintf("%s\n",menu[i]); textcolor(GREEN); textbackground(WHITE); } choix=getch(); if (choix==0) { choix=getch(); switch(choix) { case 72:{ if (nombre==0) nombre=2; else nombre--; }break; case 80:{ if (nombre==2) nombre=0; else nombre++; } break; case 73:{ nombre=0; }break; case 81:{ nombre=2; }break; } } }while(choix!=13); printf("Vous avez selectionn la rubrique nø %d ",nombre+1); getch(); }
Quand on poste du code pour aider quelqu'un, ça serait bien qu'il soit propre et compilable, parce que là...Envoyé par jacko842
L'échelle de goret a explosé...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Project : test Compiler : GNU GCC Compiler (called directly) Directory : G:\Documents\benoit\prog\test\ -------------------------------------------------------------------------------- Switching to target: default Compiling: main.c main.c:4: warning: return type defaults to `int' main.c:4: warning: function declaration isn't a prototype main.c: In function `main': main.c:8: warning: implicit declaration of function `clrscr' main.c:15: warning: implicit declaration of function `gotoxy' main.c:20: warning: implicit declaration of function `textcolor' main.c:20: error: `WHITE' undeclared (first use in this function) main.c:20: error: (Each undeclared identifier is reported only once main.c:20: error: for each function it appears in.) main.c:21: warning: implicit declaration of function `textbackground' main.c:21: error: `BLACK' undeclared (first use in this function) main.c:23: warning: implicit declaration of function `cprintf' main.c:24: error: `GREEN' undeclared (first use in this function) main.c:69: warning: implicit declaration of function `printf' main.c:85:3: warning: no newline at end of file Process terminated with status 1 (0 minutes, 0 seconds) 5 errors, 9 warnings
dsl je suis debutant je voulais aidé maintenant chez moi le code tourne bien avec turbo c
Il ne tournait pas correctement car il manquait la librairie conio.c que l'on peut trouver sur le net pour les compilateurs ne l'ayant pas par défaut comme (Devcpp ou c::b)![]()
La réponse dépend fortement de l'interface homme machine (IHM) utilisée.Envoyé par 2ismawan
- console (standard)
- texte plein écran (avec bibliothèques externes, comme PDCurses: portable)
- graphique (gtk+, API Windows etc.)
Essaye d'être plus précis dans ta demande.
Partager