OK, so I know that I can search binary records in C, by entering the number and returning the corresponding data, however I need to search a binary file using text. In my opinion I would need to load this file into a buffer and search the buffer for the required output. My problem is, if that idea is correct, I have no idea what I am doing. Can someone help please?
MichaelSammels
0
Light Poster
Recommended Answers
Jump to PostYes, I would load the file into a buffer and search the buffer for the string. When searching for the string, I would loop through each character of the buffer and compare each character to the first character of the string you are looking for. Whenever you find the first …
Jump to PostIf you'll post up a small example of the file, as an attachment, we can show it.
I'm not sure what is included in Code Snippets.
Jump to PostShow us at least what you have attempted so far.
Jump to PostUsing strchr() or strstr(), along with a smart search logic to keep it fast, is what I'd recommend. Boyer-Moore algorithm is tops, but may be much more than what you need.
Your compiler has a BUFSIZE that will be a good value to start with for your buffer array …
Jump to PostChange the %d print format to the correct %c, and see how it looks. ;)
Can you give some of the details of what you're trying to find in the text?
All 30 Replies
chrjs
42
Junior Poster in Training
MichaelSammels
0
Light Poster
Adak
419
Nearly a Posting Virtuoso
MichaelSammels
0
Light Poster
chrjs
42
Junior Poster in Training
Adak
419
Nearly a Posting Virtuoso
MichaelSammels
0
Light Poster
Adak
419
Nearly a Posting Virtuoso
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
MichaelSammels
0
Light Poster
MichaelSammels
0
Light Poster
MichaelSammels
0
Light Poster
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.