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
Post a Comment