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 8021459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:59:22+00:00 2026-06-04T21:59:22+00:00

Im having trouble accessing the following vector. Im new to vectors so this is

  • 0

Im having trouble accessing the following vector. Im new to vectors so this is probably a small syntactical thing i’ve done wrong. here is the code….

void spellCheck(vector<string> * fileRead)
{   
    string fileName = "/usr/dict/words";
    vector<string> dict;        // Stores file

    // Open the words text file
    cout << "Opening: "<< fileName << " for read" << endl;

    ifstream fin;
    fin.open(fileName.c_str());

    if(!fin.good())
    {
        cerr << "Error: File could not be opened" << endl;
        exit(1);
    }
    // Reads all words into a vector
    while(!fin.eof())
    {
        string temp;
        fin >> temp;
        dict.push_back(temp);
    }

    cout << "Making comparisons…" << endl;
    // Go through each word in vector
    for(int i=0; i < fileRead->size(); i++)
    {
        bool found = false;

        // Go through and match it with a dictionary word
        for(int j= 0; j < dict.size(); j++)
        {   
            if(WordCmp(fileRead[i]->c_str(), dict[j].c_str()) != 0)
            {
                found = true;   
            }
        }

        if(found == false)
        {
            cout << fileRead[i] << "Not found" << endl; 
        }
    }
}

int WordCmp(char* Word1, char* Word2)
{
    if(!strcmp(Word1,Word2))
        return 0;
    if(Word1[0] != Word2[0])
        return 100;
    float AveWordLen = ((strlen(Word1) + strlen(Word2)) / 2.0);

    return int(NumUniqueChars(Word1,Word2)/ AveWordLen * 100);
}

The error is in the lines

if(WordCmp(fileRead[i]->c_str(), dict[j].c_str()) != 0)

and

cout << fileRead[i] << "Not found" << endl;

the problem seems to be, because its in the form of a pointer the current syntax im using to access it is made invalid.

  • 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-04T21:59:23+00:00Added an answer on June 4, 2026 at 9:59 pm

    You can use the unary * to get a vector& from a vector*:

    cout << (*fileRead)[i] << "Not found" << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully this should be a quick question. I'm having trouble accessing some movie clips
Having trouble accessing javascript code in a mixed html/js ajax response. jQuery ajax doc
I'm having trouble accessing my IIS 7.5 express site in FireFox but i can
I am having trouble accessing the data field. I receive the error: Databinding methods
I'm having trouble accessing the id , area and theme values in my ViewData.
CakePHP Newbie :) I am having trouble accessing another controller and passing that data
I'm having trouble accessing springSecurityService from resources.groovy file, I'm trying to load user locale
So I am having some trouble accessing my model errors within my Razor view.
I am having some trouble accessing a stateful session bean (SFSB) from an application
I'm having trouble creating an Access table using VBA, then accessing it via open-recordset.

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.