Thread: Preprocess C file

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    4

    Preprocess C file

    Hello everyone I have a problem to solve and I need your help/suggestions
    I have a simple C code (program1.c)

    I need to create another program that takes the first one (program1.c), and when I find a line with comments (//), take them out . Then, after modified, the first program must be ready for compile.
    Its possible?

    Thanks!!
    Last edited by Salem; 10-30-2019 at 11:22 PM. Reason: Font size abuse

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yes, it's possible. If you are only concerned with line-based comments, then it's pretty trivial as you can read line by line and just print each line until the part when the comment is found.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2017, 10:48 AM
  2. Replies: 6
    Last Post: 12-28-2015, 03:36 AM
  3. Replies: 3
    Last Post: 11-28-2012, 09:16 AM
  4. Replies: 11
    Last Post: 09-25-2011, 12:22 AM
  5. Replies: 4
    Last Post: 07-06-2006, 02:53 AM

Tags for this Thread