answersLogoWhite

0


Best Answer

/ sub.c Copyright 2009 vishnuprathish This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. / #include int main(int argc, char** argv) { FILE *fp; fp=fopen("sub.c","r"); char ch; ch=getc(fp); while(ch!=EOF) { if(ch=='/') { ch=getc(fp); if(ch=='/') { while((ch=getc(fp))!='\n') { getc(fp);//This commment wil be removed } } if(ch=='*')/*This also wil be removed*/ { while(1) { ch=getc(fp); if(ch=='*') { ch=getc(fp); if(ch='/') { break; } } } } } printf("%c",ch); ch=getc(fp); } return 0; }

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to remove all comments from a c program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }


What is comment in c programming?

COMMENT:- comment a re not necessary in the program. however, to understand the flow of programs the programmer can include comments in the program. comment are to be inserted by the programmer. It is useful for documentation.Comment are nothing but some kind of statements which are placed between the delimiters /* & */. The compiler does not execute comments. Thus, we can say that comments are not the part of executable program.The user can frequently use any number of comments that can be placed any where in the program. Please note that the comments and statements can be nested. The user should select the OPTION MENU of the editor and select the COMPILER - SOURCE -NESTED COMMENTS ON/OFF). The Comments can be inserted with a single statement or in nested statement.Types of comment in c/c++. is following bellow1. // this is a single line comment2. /* */ this sing is multi line OR nested line commentseg. /* int i=90;char ch=65; */ close multi line commentsmade by [ARUN KUMAR RAI]


A new programmer whom you are training is writing a C program and wants to place comment lines in the program what characters should be used at the beginning and end of the comments?

if single line comment just place // before for single line comment else if multiple line denote as like this /*............................. ..............................*/ Strictly speaking, // is non.standard in C only in C++


What is the main purpose of using comments in c plus plus?

The main advantage of the newer C++ comment syntax is that you only need to start the comment, and you can expect that it will last only until the end-of-line. With the older syntax, you needed to also stop the comment. any statement; /* old comment syntax */ any statement; // new comment syntax

Related questions

How do you remove comment from c program?

There are no comments in C programs. Comments only exist in the source code and the precompiler automatically strips them out before the compiler sees them.


Can comments be longer than one line and if yes how?

C++ also supports C program's multiple command line /* your command */.


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }


What C program for display in triangle?

Please visit http://talentsealed.blogspot.com/2009/10/to-display-triangle-using-c-programming.html for the answer. Please let me know your comments


How to remove the antivirus program?

don't bother. it does not infect your computer as whole only the user a/c. create a new user a/c re-install all your info in new a/c then delete infected a/c.


Why do programmers add comments to their code even though the computer itself ignores them?

The comments are there to (a) aid in debugging the program, (b) help the programmer layout the program in logical steps and (c) show anyone else looking at the code to see what each section of the code actually does.


What is comment in c programming?

COMMENT:- comment a re not necessary in the program. however, to understand the flow of programs the programmer can include comments in the program. comment are to be inserted by the programmer. It is useful for documentation.Comment are nothing but some kind of statements which are placed between the delimiters /* & */. The compiler does not execute comments. Thus, we can say that comments are not the part of executable program.The user can frequently use any number of comments that can be placed any where in the program. Please note that the comments and statements can be nested. The user should select the OPTION MENU of the editor and select the COMPILER - SOURCE -NESTED COMMENTS ON/OFF). The Comments can be inserted with a single statement or in nested statement.Types of comment in c/c++. is following bellow1. // this is a single line comment2. /* */ this sing is multi line OR nested line commentseg. /* int i=90;char ch=65; */ close multi line commentsmade by [ARUN KUMAR RAI]


What is the purpose of using comments in c plus plus?

Comments are to help other programmers (or yourself in the future) to understand what is going on in a program, especially when the code itself is complicated and may not be obvious. More time is spent maintaining and improving programs than original development, so leaving clear comments is very important!


Do compiler see the comments written with in the C programming?

It ignores the comments, those are for the human reader.


What are the ways to comment statement in C?

Most of C/C++ will support two types of comments:* // Comment text goes here (aka inline)* /* Comment goes here */ (aka block)But the first comment type is not in ANSI C standard, you will get an error message.In order to compile your program with ASNI C standard using GCC, I suggest this:gcc -Wall -ansi -pedantic -oRemoving "-ansi" would allow usage of the first type comments in C language.


A new programmer whom you are training is writing a C program and wants to place comment lines in the program what characters should be used at the beginning and end of the comments?

if single line comment just place // before for single line comment else if multiple line denote as like this /*............................. ..............................*/ Strictly speaking, // is non.standard in C only in C++