Help on a simple "opening file" program :/

This is a discussion on Help on a simple "opening file" program :/ within the Linux Programming forums, part of the Platform Specific Boards category; Hello people i need your help:
I got this code
Code:
#include<stdio.h>
int main()
{ FILE *f;
f=fopen("animalist.txt","r");
getchar();
return ...

Help on a simple "opening file" program :/

My problem is that although animalist.txt is in the same folder my program runs i don't get the contents of my text and i just have to press ctrl+C to end my program.
Moreover,i want my program to ask me which path to navigate then give me an "ls" of the files that exist in the directory i chose and finaly open a file of my choice?Any ideas? :/

Then your program should read the contents of the file and print the contents of the file. (You probably don't have to do the whole file at once; read a line, print a line, read a line, print a line, etc. should suffice.)