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

I would read line by line and check the first seven characters for a match..Try the function

int strncmp(const char *s1, const char *s2, size_t n);

I would read line by line and check the first seven characters for a match..Try the function

int strncmp(const char *s1, const char *s2, size_t n);

Thank you :) I'll give that a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.