Advertisement
shawonrog

06(Remove single line comment)

Oct 22nd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. void cheakComment(char);
  4. void lineComment();
  5. FILE *f1, *f2;
  6. int main(){
  7.  
  8. f1=fopen("input.txt","r");
  9. f1=fopen("output.txt","w");
  10. char c;
  11. while((c=fgetc(f1))!=EOF){
  12. cheakComment(c);
  13.  
  14. }
  15.  
  16. fclose(f1);
  17. fclose(f2);
  18.  
  19. return 0;
  20. }
  21. void cheakComment(char c){
  22. if(c=='/'){
  23. char d;
  24. d=fgetc(f1);
  25. if(d=='/'){
  26. lineComment();
  27. }
  28. else{
  29. fputc(c,f2);
  30. fputc(d,f2);
  31. }
  32. }
  33.  
  34.  
  35. else{
  36. fputc(c,f2);
  37. }
  38. }
  39. void lineComment(){
  40. char e;
  41. while((e=fgetc(f1))!=EOF){
  42. if(e=='/n'){
  43. return;
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement