Unix c reading file example and returning string value

unix c
I would like small  c program example that would
read 2 line of file and return it's value.
I hope you can return string value from main function.
Who is Participating?
Infinity08Connect With a Mentor Commented:
Take a look at these standard functions (in header <stdio.h>) :

1) fopen : opens a file

2) fclose : closes a file

3) fgets : read a line from a file

4) printf : write output to the standard output (screen)

Also, make sure to look at the examples at the bottom of each of those pages ... they show you how to use the functions.

>> I hope you can return string value from main function.

Not with a return statement - main has to return int. You can send it to standard output using printf (see earlier), or you can write it to a file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.