From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/EXAMPLES/strpbrk.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 reference/C/EXAMPLES/strpbrk.c (limited to 'reference/C/EXAMPLES/strpbrk.c') diff --git a/reference/C/EXAMPLES/strpbrk.c b/reference/C/EXAMPLES/strpbrk.c new file mode 100644 index 0000000..9c33f7a --- /dev/null +++ b/reference/C/EXAMPLES/strpbrk.c @@ -0,0 +1,48 @@ + +/* + * field.c + * + * Dave Doolin 12 May, 1995 + * + * Turns miscellaneous field separators into just a space separating tokens for + * easy parsing by SSCANF. Eventually, the character separators and + * replacement character will be passed in as strings. + * + */ + +#include +#include +#include + +#define LINE_BUF 100 + +void find_comment(char *); + +main() +{ + char line[LINE_BUF]; + char *sep; + int var1, var2; + + while (fgets(line, LINE_BUF, stdin)) + { + + /* + * Check this out: Since SEP is a pointer to type char, when line is + * assigned to sep, really the first address is assigned to sep. LINE + * is the address of the start of the string. In contrast, LINE[0] + * is the first character of the string. + */ + + sep = line; + + while (sep != 0) + { + sep = strpbrk(line, ";.&:,"); + if (sep != 0) + *sep = ' '; + } + fputs(line, stdout); + } + return 0; +} -- cgit v1.2.3-54-g00ecf