How to read a line if it begins with a certain string?

Discussion in 'C' started by itsbrad212, Aug 28, 2010.

  1. itsbrad212

    itsbrad212 New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,
    I've been banging my head against the wall with this for a while. How can I read from a file if it begins with a certain string of text? Example:

    ...other lines...
    depends=('curl' 'zsh')
    ...other lines...

    I want to read the line in that file that starts with "depends". I was thinking of using fgets() but I don't know how this could be achieved.

    Thanks in advance :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice