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 //

sed 's#\/\/.*##g' myfile.c

Is that what you mean?

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 :slight_smile:

That line of code removes C comments (of the form // ) from C source files.