system()

Giorgos Keramidas keramida at hades.hell.gr
Tue Aug 24 04:47:31 EEST 1999


On Mon, Aug 23, 1999 at 02:39:49AM +0300, NooBiouZ the UnstoPPaBLouZ SeXiouZ maChinouZ wrote:
| > mporo meta px apo system("echo delta"); na paro piso to "delta" se ena
| > string?
| 
| Egw thelw na kanw akribws to antitheto dhladh na metaferw ena string sthn 
| system...exei kaneis kamia idea?

	#define MEGALO_NOUMERO 65536

	char buf[MEGALO_NOUMERO];

	sprintf(buf, "system echo \"%s\" >> file.txt", filename);
	system(buf);

alla autos sigoura den einai ki o pio kalos tropos na kaneis append se ena
arxeio. dokimase kalitera to:

	FILE *fp;

	if ((fp = fopen(filename, "a+")) == NULL)
		error("could not append to database");

	fprintf(fp, "kati_xalasmena_xapia.mp3");
	fclose(fp);

Einai pio kalos tropos na kaneis append, kai douleuei se ola ta leitourgika
me ton idio (peripou tropo).  Gi' auto legetai `standard I/O library'
eksallou auth pou exei to printf(), fprintf(), ktl.

| Episis etsi kai dwsw ws onoma album px : Ride - Nowhere kai to kanw printf mou 
| emfanizetai mono to Ride den apothikeyei pera apo to xarakthra tou kenou 
| pws mporw na to kanw na blepei kai pera apo auto?

Nai, an den prosekseis ta quotes sto command pou tha kaneis system() isos
tin patiseis.  Gi' auto protimnse ton deutero tropo pou egrapsa parapano.

-- 
Giorgos Keramidas, <keramida at ceid.upatras.gr>
Public PGP key at finger://keramida@diogenis.ceid.upatras.gr/
"Today is not yesterday's tomorrow, but tomorrow's yesterday."
--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
Ta archives tis listas einai sto http://lists.hellug.gr/archives
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users at hellug.gr
====================================================================



More information about the Linux-greek-users mailing list