|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Apr 2002
Città: Vigevano(PV)
Messaggi: 2124
|
[C]Statistiche
Codice:
#include <stdio.h> #include <stdlib.h> #include <ctype.h> typedef unsigned short uint; #define SAFE_DELETE(ptr) free(ptr); ptr = NULL; #define WARN_IF(EXP) \ do { if (EXP) fprintf (stderr, "Warning: " #EXP "\n"); } while (0); \ void ExitFunction(void) { char esc; scanf("%s", &esc); } int main(int argc, char *argv[]) { uint space = 0, digit = 0, error = 0; FILE *fin = fopen("in.txt", "r"); WARN_IF(fin == NULL) char ch; while(!feof(fin)) { ch = getc(fin); if(isalnum(ch)) ++digit; else if(isspace(ch)) ++space; else ++error; } puts("\t\t\t\t**STATISTIC PROGRAM**"); puts("\t Space \t\t Digit \t\t Error"); printf("\t %d \t\t %d \t\t %d\n", space, digit, error); SAFE_DELETE(fin); ExitFunction(); return 0; } Secondo voi nd sbaglio??? Tnk
__________________
Gnu/Linux User ![]() Ultima modifica di Luc@s : 01-06-2004 alle 08:17. |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Apr 2002
Città: Vigevano(PV)
Messaggi: 2124
|
sistemato
![]()
__________________
Gnu/Linux User ![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:48.