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

Edited by itsbrad212: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by itsbrad212
0

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

Edited by gerard4143: n/a

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.