remove single-line comment


 
Thread Tools Search this Thread
Top Forums Programming remove single-line comment
# 1  
Old 04-08-2006
remove single-line comment

Does anyone knows how to write a program to remove single-line comment in C program?

that means it don't read anything behind //
# 2  
Old 04-09-2006
Code:
sed 's#\/\/.*##g' myfile.c

Is that what you mean?
# 3  
Old 04-09-2006
oh
i mean that if i key in //
it ignore the string behind it.
for example
when i type
/bin/ls() // This is a comment
it will execute /bin/ls and ignore everything behind this line Smilie
# 4  
Old 04-09-2006
That line of code removes C comments (of the form // ) from C source files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove Comment Lines From Script/Input File

Hello, I have a SAS code that predominantly has comments line and the real code like below and i want to remove ONLY THE COMMENTS from the code in the single line or spanned across multiple lines. /******************************************************************** *** This Is a Comment... (4 Replies)
Discussion started by: arooonatr
4 Replies

2. Shell Programming and Scripting

Remove single @ on line from file

Hi All, So I have to remove all the @hostnames from a file, the problem is, there are instances where @ is used for other things... For example: example text: @This is some text in between some at signs@ @This is some more text@ This is a line that will contain a username and his/her... (5 Replies)
Discussion started by: joeg1484
5 Replies

3. Shell Programming and Scripting

Remove single-line breaks only in document

Regarding copy/pasted text of copyright-free book from archive.org (link below), in attempt to expand single-line-break paragraph text (not section headings or paragraph breaks) to wider right margin, Justify or Wrap in LIbreOffice is not working, and Find/Replace the paragraph mark ($) wraps all... (2 Replies)
Discussion started by: p1ne
2 Replies

4. UNIX for Dummies Questions & Answers

Remove multi line and single line comments

Hi, I am trying to remove multi line and single line comments like examples below I have tried this pattern. it works fine for single line comments and multi line comments in a single line only. but this fails when the comments are extended in multiple lines as shown in the comment 2 of... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

5. Shell Programming and Scripting

add line and remove comment in some script

Hi, i need some help. i am not sure about my idea. I have a script directory under my home directory,which has a lot of scripts in it. These are some names of the scripts in /axxhome/prdv/script aly300.sh axt300.sh arv300.sh clp300.sh ctth300.sh aly400.sh axt400.sh arv400.sh... (6 Replies)
Discussion started by: debu000
6 Replies

6. Shell Programming and Scripting

Need perl regular expression to remove the comment

I need a perl substitution to remove only the comment in the line . That line may have '#' with in double quotes .I used the following , s/(^.*\".+?#.+?\".+?)(#.*)/$1/g It works for , print " not a comment # not a comment " . "not a comment # not a comment" ; # It is a comment ... (3 Replies)
Discussion started by: karthigayan
3 Replies

7. Shell Programming and Scripting

Remove the comment symbol ' from a file.

I want to remove the commented lines in a file identified by ' symbol at the start of each ine. A sample example will be like: Input ----- 'IFerr_flag=0THEN iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then Output -------... (3 Replies)
Discussion started by: joyan321
3 Replies

8. UNIX for Dummies Questions & Answers

how to replace a text of line with a comment line

I want to replace this line : "test compare visible] true" and make it "#test compare visible] true". How can I do it ? And it should be checked in many sub folder files also. (6 Replies)
Discussion started by: manoj.b
6 Replies

9. UNIX for Dummies Questions & Answers

how to remove mutilple enrty in a single line in unix

Hi, Below is a single line output. subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,common,00000000 subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,01,baoc|notActive|notInduced,activeAndOperative,notActive,notActive,noneDesignated,0,notActive|00|,notActive|00|,notActive|00|,notActive|00|30|,,... (4 Replies)
Discussion started by: kaprus
4 Replies

10. UNIX for Dummies Questions & Answers

Trying to remove single character from a line

Here is a sample code grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g' the input file has data as such 903-xxx-xxxxB 903-xxx-xxxxB It is a dialer file i want to remove the "B" any help thanks (5 Replies)
Discussion started by: Iz3k34l
5 Replies
Login or Register to Ask a Question