Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9075861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:58:09+00:00 2026-06-16T18:58:09+00:00

I want to extract some integers from a file using C++, but I am

  • 0

I want to extract some integers from a file using C++, but I am not sure if I am doing it correctly.

My code in VB6 is the following:

Redim iInts(240) As Integer
Open "m:\dev\voice.raw" For Binary As #iFileNr
Get #iReadFile, 600, iInts() 'Read from position 600 and read 240 bytes

My conversion to C++ is the following:

vector<int>iInts
iInts.resize(240)

FILE* m_infile;
string filename="m://dev//voice.raw";

if (GetFileAttributes(filename.c_str())==INVALID_FILE_ATTRIBUTES)
{
  printf("wav file not found");
  DebugBreak();
} 
else 
{
  m_infile = fopen(filename.c_str(),"rb");
}

But now I don’t know how to continue from there, and I also don’t know if “rb” is correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:58:10+00:00Added an answer on June 16, 2026 at 6:58 pm

    I don’t know how VB reads a file but if you need to read integers from a file try:

    m_infile = fopen(myFile, "rb")
    fseek(m_infile, 600 * sizeof(int), SEEK_SET);
    // Read the ints, perhaps using fread(...)
    fclose(myFile);
    

    Or you can use the C++ way using ifstream.

    Full example with streams (note, you should add error checking):

    #include <ifstream>
    
    void appendInts(const std::string& filename, 
                    unsigned int byteOffset, 
                    unsigned int intCount,
                    const vector<int>& output)
    {
        std::ifstream ifs(filename, std::ios::base::in | std::ios::base::binary);
        ifs.seekg(byteOffset);
        for (unsigned int i = 0; i < intCount; ++i)
        {
            int i;
            ifs >> i;
            output.push_back(i);
        }
    }
    
    ...
    
    std::vector<int> loadedInts;
    appendInts("myfile", 600, 60, loadedInts);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP Regular Expression I want to extract some value from code <?xml version=1.0
I want to extract images from an PDF. I'm using iTextSharp right now. Some
I want to extract some elements from each line of a file. Below is
I want to use ADO.net to extract some data from an Excel file. This
I want to extract some specific lines from a text file to other text
I want to extract some data from a file and save it in an
I have an xml file that I want to extract some specific fields from
I want to extract some links from a XML document (links are in same
I want to extract some numbers from the input line which is a string.
I'm new to python. I want to extract some text from the CNN website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.