Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
seekg
- Page 1
seekg() is driving me nuts
Programming
Software Development
15 Years Ago
by EgyCoder
…::in); binaryFile.clear(); binaryFile.
seekg
(32); counter=0; while …counter++; cout << endl; binaryFile.
seekg
( -36, ios::cur); binaryFile.read (…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by Pelle_3
…<< counter << std::endl; fbin.
seekg
(recSize * i); fbin.read(temp, sizeof(name)); if… //ask for record n = get_int(0); fbin.
seekg
(recSize * n); //jump to record fbin.read(…break; if (strlen(temp) != 0) counter++; } fbin.
seekg
(0); //reset reading position return counter; } void print_all_records() {…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by tetron
…adding the [icode]ios::beg[/icode] [CODE]fbin.
seekg
(0, std::ios::beg);[/CODE] if this doesn't…;1173670]Why do I have do use the
Seekg
()-function two times in a row to make it… work? Code: [CODE] fbin.
seekg
(0); //jump to record at start of file …fbin.
seekg
(0); //jump to record a second time …
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by Pelle_3
… adding the [icode]ios::beg[/icode] [CODE]fbin.
seekg
(0, std::ios::beg);[/CODE] if this doesn't…"; //ask for record n = get_int(0); fbin.
seekg
(0); fbin.
seekg
(recSize * n); //jump to record fbin.read(name, …0; for (int i = 0; !fbin.eof(); i++) { fbin.
seekg
(recSize * i); fbin.read(temp, sizeof(name)); if (strlen(temp…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by Pelle_3
…at your code and haven't spotted the mistake. [icode]
seekg
(pos)[/icode] should be setting an offset. However, I'… What I suggested before is make line 92: [CODE]fbin.
seekg
(recSize * n, ios::beg);[/CODE] without line 91 this …to use an offset from the explicit position start the
seekg
() returns a value that might be showing an error.[/…
Re: seekg() is driving me nuts
Programming
Software Development
15 Years Ago
by WaltP
I'd be more interested in knowing why you need [iCODE]
seekg
()[/iCODE]. This doesn't look like a binary search. Just looks like you're bouncing around a file for the sake of bouncing where just reading the file would be more efficient and less error-prone.
Seekg()-problem
Programming
Software Development
15 Years Ago
by Pelle_3
… in a row to make it work? Code: [CODE] fbin.
seekg
(0); //jump to record at start of file fbin….
seekg
(0); //jump to record a second time (else it won'…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by tetron
…at your code and haven't spotted the mistake. [icode]
seekg
(pos)[/icode] should be setting an offset. However, I'm… What I suggested before is make line 92: [CODE]fbin.
seekg
(recSize * n, ios::beg);[/CODE] without line 91 this says… use an offset from the explicit position start the
seekg
() returns a value that might be showing an error.
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by tetron
…; " " << counter << std::endl; fbin.
seekg
(recSize * i); fbin.read(temp, sizeof(name)); if (strlen(temp… don't understand why. As long as i write fbin.
seekg
(recSize * n, ios::beg), it shouldn't be of any…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by tetron
…, but it gave no result. I actually though that the
seekg
and seekp functions set the absolute position in the file…
Re: Seekg()-problem
Programming
Software Development
15 Years Ago
by Pelle_3
… don't understand why. As long as i write fbin.
seekg
(recSize * n, ios::beg), it shouldn't be of any…
seekg() not working to find record with corresponding record number
Programming
Software Development
14 Years Ago
by aladar04
… using the Record Number inputted by the user. I used
seekg
() but it doesn't work. I have attached the files…
Re: seekg() not working to find record with corresponding record number
Programming
Software Development
14 Years Ago
by alwaysLearning0
You have bytesPerRecord=38 but accounts.txt has different size of records which ultimately messing up your
seekg
calculation. Make sure all the records in account.txt is of size 38 bytes.
Re: seekg() not working to find record with corresponding record number
Programming
Software Development
14 Years Ago
by alwaysLearning0
You have bytesPerRecord=38 but accounts.txt has different size of records which ultimately messing up your
seekg
calculation. Make sure all the records in account.txt is of size 38 bytes.
seekg() C++
Programming
Software Development
14 Years Ago
by danijela123
…]for(i=4; i<100;i=i+2){ datafile.
seekg
(i,ios::beg); datafile.read((char*)&dataCount,2*sizeof…
Re: seekg() C++
Programming
Software Development
14 Years Ago
by danijela123
…: [CODE]short spremi; // 2 byte int dataCount; // 4 byte datafile.
seekg
(0,ios::beg); datafile.read(reinterpret_cast<char*>(&…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by vijayan121
…n\n" ; string str ; cout.imbue( german ) ; file.
seekg
( namepos ) ; getline( file, str ) ; cout << …str << '\n' ; file.
seekg
( addresspos ) ; getline( file, str ) ; cout << str …<< '\n' ; file.
seekg
( phonepos ) ; getline( file, str ) ; cout << str …
Re: problem with seekg
Programming
Software Development
17 Years Ago
by vijayan121
… the eofbit first. [CODE] file.clear() ; file.
seekg
( 0, std::ios::beg ) ; [/CODE] the
seekg
you are doing is ok because you… the beginning of the file. for a
seekg
to some non-zero offset (or a
seekg
from the end) to work reliably…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by vijayan121
…escape sequence translations during input/output. all that
seekg
on an fstream does is call filebuf::seekpos…quot;test.txt" ) ; // open in text mode file.
seekg
( 0, std::ios::beg ) ; const std::streampos beginpos =… file.tellg() ; file.
seekg
( 0, std::ios::end ) ; const std::streampos endpos = file…
problem with seekg
Programming
Software Development
17 Years Ago
by jesseb07
… just before the second part to remedy that: [CODE] file.
seekg
(0, ios::beg); [/CODE] however, it doesn't seem to…, it says -1 whether I have the
seekg
there or not. to make sure
seekg
was the problem, I tried closing the…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by Ancient Dragon
…;>then file.clear() and file.
seekg
(...) shouldn't work correctly either clear() and
seekg
() work in either binary or text mode….
seekg
() just has a few limitations in text…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by vijayan121
> file.clear() and file.
seekg
(...) shouldn't work correctly either? >If that's the … in binary? file.clear() will work in all cases. file.
seekg
(...) will work in all cases if you seek to the…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by Ancient Dragon
[QUOTE=vijayan121;544536] file.
seekg
(...) will work in all cases if you seek to the [… probably accurate, but I have no idea what it is.
seekg
() works the same in both text and binary mode on…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by krnekhelesh
Yeah I agree with vijayan. File pointers like
seekg
(),tellg() work correctly only with Binary Files where the read() and write() functions are used.
Re: problem with seekg
Programming
Software Development
17 Years Ago
by jesseb07
…; ifstream myfile ("example.txt"); begin = myfile.tellg(); myfile.
seekg
(0, ios::end); end = myfile.tellg(); myfile.close(); cout <…
Re: problem with seekg
Programming
Software Development
17 Years Ago
by jesseb07
ok, so file.eof() would only work (correctly) if the file is opened in binary mode? With that in mind, then file.clear() and file.
seekg
(...) shouldn't work correctly either? If that's the case, is there any way I can return to the beginning of the file without opening it in binary? I appreciate the help! ~J
Binary Files and Seekg
Programming
Software Development
16 Years Ago
by strickenUK
… and then read data from the binary file and use
seekg
to display specific data depending on what is entered by…;< "Which Record? "; cin >> recNo; in.
seekg
(recNo*20 + sizeof(double), ios::beg); temp.read_in(in); cout…
Re: Binary Files and Seekg
Programming
Software Development
16 Years Ago
by Narue
… of code have the same incorrect math: [code=cplusplus] in.
seekg
(recNo*20 + sizeof(double), ios::beg); [/code] [code=cplusplus] int… foo = recNo * 20; in.
seekg
(foo + sizeof(double), ios::beg); [/code] This is painfully obvious…
Re: Binary Files and Seekg
Programming
Software Development
16 Years Ago
by strickenUK
… of code have the same incorrect math: [code=cplusplus] in.
seekg
(recNo*20 + sizeof(double), ios::beg); [/code] [code=cplusplus] int… foo = recNo * 20; in.
seekg
(foo + sizeof(double), ios::beg); [/code] This is painfully obvious…
seekp & seekg is not working....
Programming
Software Development
14 Years Ago
by iamcreasy
… reset the position of the pointer.But, the seekp and
seekg
methods are not working...the pointer is not being reset… + 10*y + z; _temp << (teacherID * 100 + i); inStream.
seekg
(0, ios::beg); outStream.seekp(0, ios::beg); while(getline…
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC