473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

seek() function

hi all,for example there is a text file and in this file 'pencil' is
written if part of the program is like that:

ifstream fin("pen.txt");//in this file pencil is written

char c;
fin.get(c);
cout<<c;//output is p

c=fin.peek();
cout<<c;//output is e

c=fin.peek();
cout<<c;//output is still e

at the second seek function why is the value of c doesnt change to n?

Sep 15 '05 #1
4 20046
On 14 Sep 2005 18:16:28 -0700, "berkay" <be**********@gmail.com> wrote:
hi all,for example there is a text file and in this file 'pencil' is
written if part of the program is like that:

ifstream fin("pen.txt");//in this file pencil is written

char c;
fin.get(c);
cout<<c;//output is p

c=fin.peek();
cout<<c;//output is e

c=fin.peek();
cout<<c;//output is still e

at the second seek function why is the value of c doesnt change to n?


Because peek() doesn't advance the file position (i.e. "cursor" into the
file).
Sep 15 '05 #2
so does it mean that number of the fundtions is not important?

Sep 15 '05 #3

"berkay" <be**********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
so does it mean that number of the fundtions is not important?


peek() is specifically to "peek" at the next character without changing the
file pointer.

You could call peek a million times in a row, and it wouldnt' change where
the file pointer was pointing to. That's what it was designed for.
Sep 17 '05 #4
ok i think i understood,thanks

Sep 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Denardo | last post by:
Does anyone have any good VB.NET example code that shows how to use the NOTIFY option using the mciSendString API and then handle the return value. The only examples I can find show the VB way...
33
by: Kevin Brammer | last post by:
I'm trying to use seek to check for the existence of a record before saving, so there are no duplicate entries (is there another way?). I have a "groups" table, which has GroupID Island...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
6
by: ataanis | last post by:
Hi, Can anybody tell me , why if I change the second value in the read() function, I get an error message, I'm dealing here with a file, that has at least 240 caracters per line Private Sub...
4
by: Terry | last post by:
Hi, I am both new to .Net (coming from VB6 and DAO) and to this news group. I am trying to convert some code from VB6 that uses a "record set" to help the user locate a specific record. As the...
3
by: Jonnh | last post by:
help with use the methods recordset and seek in access because en excel with function database, i know but en access i need seek to table or form, thanks
1
by: Harsh682 | last post by:
hi, i am using a StreamReader to read the file but i need to go back when certain match not found.this is demo code in which i am trying to go back certain positions. FileStream fs1 = new...
3
by: Michal | last post by:
Does any one know how to create a function that works similar as "Goal Seek" in Excel? For example: var a=8; var b=6; function c(a,b) { return a*b; }
4
by: vineeta | last post by:
Hi All, I was trying to overwrite the data in a file. But seek function is not working as i expecting. My code is here: public void createfile() { FileStream fs = new...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.