1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    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