Hello..,,
I have read about a function used in file handling named as "peek".
If anyone knows about this function then plz tell me.....

Recommended Answers

All 4 Replies

I've found 4 functions with start "Peek" (and they was found at win32.hlp, that you could find with google), that are:
PeekConsoleInput
PeekMessage
PeekNamedPipe
PeekPenInput
Searching on msdn will give you the required information, hope it helps =).

peek basically reads the next available character without moving the file pointer.

for example if text file contains the following text

Hello, World

and if you execute the following psuedo Code

int main ()
{
   // open stream.
   char v =  f.peek();

 // the below line will print 'H' but will not extract this character from stream.
  cout << v <<endl;
}

if you don't want to move your reading cursor and wants to check which character will be read next you should use peek.

can u tell me from where I can get more information about file handling and the functions of it..

can u tell me from where I can get more information about file handling and the functions of it..

Google it! "C++ peek" gives the following as the first link.

http://www.cplusplus.com/reference/iostream/istream/peek/

Bookmark the entire site.

http://www.cplusplus.com

It's your first stop before you ask a question on a forum. Type what you are asking about in its search engine. It has all the functions and all the libraries and examples. And a tutorial section.

http://www.cplusplus.com/doc/tutorial/

Bookmark that too.

Scroll down till you get to the "Input/Output With Files" section.

http://www.cplusplus.com/doc/tutorial/files/

If you don't like this site, type "C++ tutorial" into google or Daniweb or wherever. You need to do all of this before posting.

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.