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

  • SEARCH
  • Home
  • 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 7563841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:46:03+00:00 2026-05-30T13:46:03+00:00

Hi every one I have the following problem I need to build a vector

  • 0

Hi every one I have the following problem I need to build a vector array from a file.
I managed to creat a vector by reading the file into a string buffer then saving it into this following vector.

vector<char> pattern(contents.begin(), contents.end());

But I have the following function that I need to pass the vector to.

void WuManber::Initialize( const vector<const char *> &patterns, 
                      bool bCaseSensitive, bool bIncludeSpecialCharacters, bool bIncludeExtendedAscii )

how can I read from a file a passable vector to this function.
thank you for your help.

to elaborate more I need it to do the following

for ( size_t q = m; q >= B; --q ) 
  { // start loop -8-

  unsigned int hash;
  hash  = m_lu[patterns[j][q - 2 - 1]].offset; // bring in offsets of X in pattern j
  hash <<= m_nBitsInShift;
  hash += m_lu[patterns[j][q - 1 - 1]].offset;
  hash <<= m_nBitsInShift;
  hash += m_lu[patterns[j][q     - 1]].offset;
  size_t shiftlen = m - q;
  m_ShiftTable[ hash ] = min( m_ShiftTable[ hash ], shiftlen );
  if ( 0 == shiftlen ) 
 {  // start if -8-
    m_PatternMapElement.ix = j;
    m_PatternMapElement.PrefixHash = m_lu[patterns[j][0]].offset;
    m_PatternMapElement.PrefixHash <<= m_nBitsInShift;
    m_PatternMapElement.PrefixHash += m_lu[patterns[j][1]].offset;
    m_vPatternMap[ hash ].push_back( m_PatternMapElement );
  } // end if -8-

int main(int argc, char* argv[])
{
if (argc < 2) {
  std::cout << "usage: " << argv[0] << " <filename>\n";
  return 2;
 }

 ifstream fin(argv[1]);
 if (fin) {
  stringstream ss;
  // this copies the entire contents of the file into the string stream
  ss << fin.rdbuf();
  // get the string out of the string stream
  string contents = ss.str();
  cout << contents;
  // construct the vector from the string.
  vector<char> pattern(contents.begin(), contents.end());
  Initialize( &pattern);
  cout << pattern.size();
 }
 else {
  cout << "Couldn't open " << argv[1] << "\n";
  return 1;
 }
 return 0;
}
  • 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-05-30T13:46:04+00:00Added an answer on May 30, 2026 at 1:46 pm

    The function is looking for a vector of C strings (that’s the most likely meaning of const char * inside a container named patterns.

    Here is how you can build one:

    std::vector<const char*> patterns;
    patterns.push_back("my-first-pattern");
    patterns.push_back("my-second-pattern");
    

    If you or your team designed this function, you may want to suggest changing the container type to a more C++ – ish vector<string>.

    If you are reading your patterns from a file, you can populate your array as follows:

    EDIT (in response to a comment)

    std::ifstream ifs("file_with_patterns.txt");
    std::vector<const char*> patterns;
    while (!ifs.eof()) {
        std::string buf;
        std::getline(ifs, buf);
        patterns.push_back(strdup(buf.c_str()));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following problem: i need to send some custom info with every
I have the following problem. I need to organize automatic upload to deploy server
I have this homework problem where I need to use regex to remove every
i have one image background of table with following syntax style=background-image(URL) the problem is
I ran into the following problem and cannot decide how to proceed: I have
I need to build ONE regular expression that can detect ALL the following strings
I have the following problem: I have a multithreaded server-side application, where every request
I am following up from this question here The problem I have is that
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
Hai every one I am developing an windows application in which i have to

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.