Advertisement
andruhovski

Task08

Jan 19th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. // task08.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. int _tmain (void)
  7. {
  8.     FILE *stream;  
  9.     char *token, *str, seps[]   = "\r\n";
  10.     errno_t err;
  11.     int result;
  12.     long pos;
  13.  
  14.     err  = fopen_s( &stream, "08INP.txt", "r+b" );
  15.     if( err != 0 ) 
  16.         return -1; 
  17.    
  18.     fseek(stream,0,SEEK_END);
  19.     pos=ftell(stream); 
  20.     str = (char *) malloc(pos);
  21.     memset(str,0,pos);
  22.     fseek(stream,0,SEEK_SET);
  23.     fread(str,pos,1,stream);
  24.     str[pos]=0;
  25.     token=strtok(str,seps);
  26.     while( token != NULL )
  27.      {
  28.          int sl=strlen(token)-1;
  29.          result = 1;
  30.          for (int i=0;i<sl; i++)
  31.          {
  32.              if ( isdigit(token[i]) && isdigit(token[i+1]) && (!isdigit(token[i+2])))
  33.              {
  34.                  result = 0;
  35.                  break;
  36.              }
  37.          }
  38.          if (result)
  39.              puts(token);
  40.         token = strtok( NULL, seps ); // C4996
  41.      }
  42.     fclose(stream);
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement