Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
double.c
Package: c.rar [view]
Upload User: shmaik
Upload Date: 2014-06-01
Package Size: 45093k
Code Size: 1k
Category:
Visual C++ Books
Development Platform:
C/C++
- static char rcsid[] = "$Id: H:/drh/idioms/book/RCS/intro.doc,v 1.12 1997/10/27 23:05:12 drh Exp $";
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <ctype.h>
- #include <string.h>
- int linenum;
- int getword(FILE *, char *, int);
- void doubleword(char *, FILE *);
- int main(int argc, char *argv[]) {
- int i;
- for (i = 1; i < argc; i++) {
- FILE *fp = fopen(argv[i], "r");
- if (fp == NULL) {
- fprintf(stderr, "%s: can't open '%s' (%s)n",
- argv[0], argv[i], strerror(errno));
- return EXIT_FAILURE;
- } else {
- doubleword(argv[i], fp);
- fclose(fp);
- }
- }
- if (argc == 1) doubleword(NULL, stdin);
- return EXIT_SUCCESS;
- }
- int getword(FILE *fp, char *buf, int size) {
- int c;
- c = getc(fp);
- for ( ; c != EOF && isspace(c); c = getc(fp))
- if (c == 'n')
- linenum++;
- {
- int i = 0;
- for ( ; c != EOF && !isspace(c); c = getc(fp))
- if (i < size - 1)
- buf[i++] = tolower(c);
- if (i < size)
- buf[i] = '';
- }
- if (c != EOF)
- ungetc(c, fp);
- return buf[0] != '';
- }
- void doubleword(char *name, FILE *fp) {
- char prev[128], word[128];
- linenum = 1;
- prev[0] = '';
- while (getword(fp, word, sizeof word)) {
- if (isalpha(word[0]) && strcmp(prev, word)==0)
- {
- if (name)
- printf("%s:", name);
- printf("%d: %sn", linenum, word);
- }
- strcpy(prev, word);
- }
- }