[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] gotoxy lignende funktion



OK, her er et program som virker på min SuSE 6.1 .

----------------------------------------------------------------------

/* gotoxy.c - En "avanceret" Hello World. */
/* Compiler med 'gcc -o gotoxy gotoxy.c -ncurses'

#include <stdio.h>	/* printf etc. /*
#include <term.h>	/* Egentlig burde dette vist være nok. */
#include <ncurses.h>	/* Men nogen gange er denne nødvendig,
			   da terminfo of curses er tæt integrerede */

int main()
{
	char *cmd;	/* Esc. seq. skabelon	*/
	char *esc_seq;	/* Esc. seq.		*/

	/* OK, jeg havde glemt, at man skulle initialisere i
	   det oprindelige eks. Her sættes en TERMINAL struktur op,
	   så man kan spørge om forskellige capabilities. */
	setupterm((char *)0, fileno(stdout), 0);

	/* Slet skærm */
	cmd = tigetstr("clear");		/* Ingen parametre */
	if (cmd == (char*)-1) {
		printf("Fejl 1\n");
		exit(1);
	}
	putp(cmd);
	
	/* Flyt cursor */
	cmd = tigetstr("cup");
	if (cmd == (char *)-1) {
		printf("Fejl 2!\n");
		exit(1);
	}
	esc_seq = (char *)tparm(cmd, 20, 10);
	putp(esc_seq);
	
	printf("Hello world!\n");
}

----------------------------------------------------------------------

Selve det at flytte curseren fylder altså kun 4 linier (man behøver reelt
ikke teste) .
Køb i øvrigt bogen "Beginning Linux Programming, 2. ed." fra Wrox Press næste
gang i er i byen. Den er et must til at starte med. Anden udgave er ret ny,
så den skal måske bestilles hjem, jeg har selv den første, men den nyere ser
endnu bedre ud!

-- 
mvh.
Peter Seidler
sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *