Hi,

I want to do the following steps one by one

1. check whether given file is exists in the directory or not
2. if exists open the file
3.read the first line and store the values
4. got to the last line of file and store the values
5. close the file
6. if file does not exists come out of the program.

Pls Provide the sample coding to do this..

fopen creates a FILE* to the given directory. It doesn't support spaces (at least, not on Windows). It returns NULL when a file doesn't exist.

fread reads in a FILE*, parsing can be done with sscanf and your own mix of code.

Going to the last line can't be done like that. You must search for the end, then search for a newline character perhaps or something that defines a line.

fclose closes the given FILE*.

Hope this helps a bit. Finding a C reference site will help explaining the functions in more detail.

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.