All pastes #196158 Raw Edit

Anonymous

public c v1 · immutable
·published 2006-10-10 11:20 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <dirent.h>int main(int argc, char** argv){	char c[200];	int t;		if (argc < 2) {		fprintf(stderr, "Read the help file\n");		exit(1);	}		get_argv_call(argc, argv, &t, c, sizeof(c));		printf("t = %d\nc=%s\n", t, c);			return 0;}int get_argv_call(int argc, char** argv, int* t_value, char* c_value, int c_len){	int i;		for (i = 1; i < argc; i++) {		if (argv[i][0] == '-') {			switch (argv[i][1]) {				case 't' : *t_value = atoi(argv[++i]);					break;								case 'c' : strncpy(c_value, argv[++i], c_len);					break;								default: fprintf(stderr, "Unknown switch %s\n", argv[i]); exit(1);							}		} else {			fprintf(stderr, "Unknown switch %s\n", argv[i]);		}	}}