c++ - I/O redirection in C using exe -


here code:

#include<stdio.h>  int main() {     int = '\0';      while ((a = getchar()) != eof){         if (a != ' ' || != '\t' || != '\n' || != ';' || != ',' || != '.'){             putchar(a);         }         else{             continue;         }     }      system("pause");     return 0; } 

i need read poem input file, , output poem no spaces or punctuation. must done using i/o variation. i've searched over, can't seem find how way need. appreciated...

hope solves problem. use ascii values character. use fgetc/fputc/fscanf/fprintf etc file i/o related operations. ascii chart link here ascii chart values.

#include<stdio.h>   int main() {  file *pfile=null;  char data[255];  int i=0;   pfile=fopen("poem.txt","r");   while((data[i]=fgetc(pfile)) != eof)  {     if(data[i]> 32 && data[i] < 123)    {      if(data[i] != 44 && data[i]!= 45 && data[i]!=46 && data[i]!=33)      {        //in above 'if statement' can add more characters/special        //characters wish exclude/ignore        printf("%c",data[i]);        i++;      }    }  }  return 0; } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -