Verwante Seiten

Lektüre

Dynamische library

Code-Beispiele

Keepalive

Dieses Progrämmchen gibt regelmässig einen Punkt aus. So kann man zum Beispiel auf sehr sparsame Weise eine SSH-Verbindung aufrecht erhalten.

#include <stdio.h>
#include <stdlib.h>
 
int main (int argc, char **argv) {
	int delay = 6;
	if (argc > 1) {
		if (argv[1][0] == '-' && argv[1][1] == 'h' || argv[1][0] == '/' && argv[1][1] == 'h' || 
			argv[1][0] == '-' && argv[1][1] == 'H' || argv[1][0] == '/' && argv[1][1] == 'H') {
			fprintf(stderr, "    %s [Timeout]\
			\n\tdas Timeout in Sekunden. Ohne Angabe sind dies 6 Sekunden.\n", argv[0]);
			return 0;
		}
		delay = strtol(argv[1], NULL, 10);
		if (delay == 0 || delay < 0) {
			fprintf(stderr, "Keine gueltige natuerliche Ganzzahl!\nInfo: %s -h", argv[0]);
			return 1;
		}
		if (delay > 120) {
			fprintf(stderr, "Zugrosser Wert. Maximum = 120 Sekunden!\n");
			return 2;
		}
	}
	while (1) {
		printf(".");
		sleep(delay * 1000);
	}
	return 0;
}

UTF-8

Beispiel

/*
Link: http://www.cl.cam.ac.uk/~mgk25/unicode.html#c
*/
#include <stdio.h>
#include <locale.h>
 
int main(void) {
	if (!setlocale(LC_CTYPE, "")) {
		fprintf(stderr, "Can't set the specified locale! "
		"Check LANG, LC_CTYPE, LC_ALL.\n");
		return 1;
	}
	printf("%ls\n", L"Schöne Grüße");
 
	printf("\n%ls", L"Return-Taste drücken...");
	getchar();
	return 0;
}

Links

 
infos/programmieren/c.txt · Zuletzt geändert: 2009/10/23 13:26 von schule
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki