Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*multi line
- comment*/
- int main(void)
- {
- FILE *p1,*p2;
- char c,prev;
- int count=0;
- p1=fopen("input.c","r");
- p2 = fopen("parentheses.txt","w");
- if(!p1)
- printf("\n file cant be open");
- else
- {
- while ((c = fgetc(p1)) != EOF)
- {
- if(c=='\n') {}
- //comment
- else if(c=='/')
- {
- prev = c;
- if(c = fgetc(p1)=='*')
- {
- while(1)
- {
- while(c = fgetc(p1)!='*') {}
- if(c = fgetc(p1)=='/')
- {
- break;
- }
- // else
- // {
- // fputc(c,p2);
- //}
- }
- }
- else if(c = fgetc(p1)=='/')
- {
- while(c = fgetc(p1)!=10) {}
- }
- else
- {
- fputc(prev,p2);
- fputc(c,p2);
- }
- }
- //extra space
- else
- {
- fputc(c,p2);
- if (c==32 )
- {
- while((c=getc(p1))==32)
- {
- }
- fputc(c,p2);
- }
- }
- }
- fclose(p1);
- fclose(p2);
- p2 = fopen("parentheses.txt","r");
- while ((c=fgetc(p2))!=EOF)
- {
- printf("%c",c);
- }
- fclose(p2);
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement