[PRG] Une fonction similaire à clrscr() sous gcc ?

Ici vous pouvez demander de l'aide ou des conseils pour la création de Trainers. Vous programmez ? Vous avez des questions ? Vous connaissez un langage PHP, HTML, C, C++, Visual Basic etc... et vous souhaitez en faire profiter tout le monde c'est ici aussi? Vos questions et réponses sur le graphismes sur l'utilisation de logiciels 2D et 3D (comme Photoshop, Painter, 3DSMAX, Ligthwave, Flash etc...)

Moderators: Shub, Administrateurs - Adjoint, Modérateur, Administrateur, Global Moderator

Post Reply
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Bonjour :) ,
Je cherche une fonction qui permetterait d'effacer l'écran d'une console sous linux en langage C (sous gcc). Je connaissais la fonction sous dos mais elle est non exportable :( . Si quelqu'un la connais avec sa bibliothèque associée j'en serai ravi. Ou sinon il reste toujours la possibilité d'injecter un code shell dans mon code C. J'ai déja entendu que c'était possible mais je ne me souviens plus de comment faire :(

Si quelqu'un peut m'aider je le remercie d'avance :)

Yabo.

Edit :
Voilà un code exemple (encore et toujours un super prog super utile :P) :


#include <stdlib>

void vide_ecran(void);

void vide_ecran()
{
clear();
}


int main()
{
sleep(1);
printf("Hello World\n");
char MaVariable;
scanf("%c", &MaVariable);
printf("%c",MaVariable);
printf("\n");
vide_ecran();
printf("%c",MaVariable);
exit(0);
}
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Magicking
Lieutenant
Lieutenant
Posts: 432
Joined: 14 Oct 2002 - 12:18:46
Location: Le Kremlin-Bicêtre
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Magicking »

Sous linux je sais pas mais tu peux essayer de remplir l'ecran retour a la ligne (\n) :chinois:
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Ben c'est ce que j'ai fait mais c'est pas très "propre" comme méthode :(
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Magicking
Lieutenant
Lieutenant
Posts: 432
Joined: 14 Oct 2002 - 12:18:46
Location: Le Kremlin-Bicêtre
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Magicking »

Ben c'est ce que j'ai fait mais c'est pas très "propre" comme méthode
Pas propre ? C'est pas pasque tu ré-écris une fonction que sa doit pas étre propre sinon je pense qu'il y aurait beaucoup de tochon :arf:
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Mais ca "efface" pas vraiment la console, ca l'abaisse simplement. Ca me plais pas :) Et puis la programmation c'est un art :) Ca doit être beau ;)
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Magicking
Lieutenant
Lieutenant
Posts: 432
Joined: 14 Oct 2002 - 12:18:46
Location: Le Kremlin-Bicêtre
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Magicking »

Mais ca "efface" pas vraiment la console, ca l'abaisse simplement. Ca me plais pas Et puis la programmation c'est un art Ca doit être beau
Oui mais tout art a ses faiblesses :chinois: (j'ai pas d'exemple c'est une phrase qui est sortie toute seule)

Et puis qui dit que clrscr() ne fait pas la même chose ? :D
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Oui mais moi je veux une fonction clrscr() :P
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Si ca interresse quelqu'un j'ai trouvé la fonction :)

Code: Select all

printf("\033[H\033[2J");
Voilà :)
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Magicking
Lieutenant
Lieutenant
Posts: 432
Joined: 14 Oct 2002 - 12:18:46
Location: Le Kremlin-Bicêtre
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Magicking »

toujours avec ça ? :blink:
Yabo
Colonel
Colonel
Posts: 1282
Joined: 14 Oct 2002 - 19:01:58
Location: Ici.
Contact:

[PRG] Une fonction similaire à clrscr() sous gcc ?

Post by Yabo »

Bah non j'ai la solution là :-)
Image

Hacking is like sex. You get in, you get out, and hope that you didn't leave something that can be traced back to you.
Post Reply