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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:08:17+00:00 2026-05-11T02:08:17+00:00

I want to eliminate the junk that I’m getting on the vector<int> synsAux below.

  • 0

I want to eliminate the junk that I’m getting on the vector<int> synsAux below. It should print:

1  7 7 1 

I’m getting an extra 2 before the first and third digit, why? Is this 2 an ascii value for the blank space or something? How do I avoid its reading?

This is the dictionary file needed to run the program:

dictionary.txt 1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautiful synonyms 1 7 7 1 antonyms 1 3 3 1 7 4 5 5 4 7 3 

#include <iostream> #include <fstream> #include <string>  #include <sstream> #include <vector>   using namespace std;  class WordInfo{       public:              WordInfo(){}              ~WordInfo() {                   }               int id() const {return myId;}               void readWords(istream &in)              {                in>>myId>>word;                   }               void pushSynonyms (string synline, vector <WordInfo> wordInfoVector)              {                  stringstream synstream(synline);                  vector<int> synsAux;                  int num;                  while (synstream >> num) synsAux.push_back(num);                  cout<<synsAux.size();                    for (int i=0; i<synsAux.size(); i++){                       cout<<synsAux[i]<<endl;                         // THIS LINE SHOULD BE PRINTING                       //1                       //7                       //7                       //1                  }                     }               void pushAntonyms (string antline, vector <WordInfo> wordInfoVector)              {               }               //--dictionary output function              void printWords (ostream &out)              {                 out<<myId<< ' '<<word;                   }               //--equals operator for String              bool operator == (const string &aString)const              {                            return word ==aString;               }               //--less than operator              bool operator <(const WordInfo &otherWordInfo) const              { return word<otherWordInfo.word;}               //--more than operator              bool operator > (const WordInfo &otherWordInfo)const              {return word>otherWordInfo.word;}               private:                    vector <int> mySynonyms;                    vector <int> myAntonyms;                    string word;                    int myId;       };        //--Definition of input operator for WordInfo       istream & operator >>(istream &in, WordInfo &word)       {          word.readWords(in);        }        //--Definition of output operator       ostream & operator <<(ostream &out, WordInfo &word)       {             word.printWords(out);         }    int main() {       string wordFile;       cout<<'enter name of dictionary file: ';       getline (cin,wordFile);        ifstream inStream (wordFile.data());        if(!inStream.is_open())       {           cerr<<'cannot open '<<wordFile<<endl;            exit(1);                             }        vector <WordInfo> wordVector;        WordInfo aword;        while (inStream >>aword && (!(aword=='synonyms')))       {           wordVector.push_back(aword);       }        inStream.clear(); // clears failbit on the ifstream        int i=0;                 while (i<wordVector.size()){             cout<<wordVector[i]<<endl;             i++;       }        vector <int> intVector;       string synLine; //suspect        while (getline(inStream, synLine)&&(synLine!=('antonyms'))){             aword.pushSynonyms(synLine, wordVector);       }        system('PAUSE');       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. 2026-05-11T02:08:17+00:00Added an answer on May 11, 2026 at 2:08 am

    You’re printing the twos here:

    cout<<synsAux.size(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There's a lot that I could write about this Control… May 11, 2026 at 11:27 am
  • added an answer Here is how you can manage this using just Vim… May 11, 2026 at 11:27 am
  • added an answer In most languages it's the same thing. People often do… May 11, 2026 at 11:27 am

Related Questions

I want to eliminate the junk that I'm getting on the vector<int> synsAux below.
I want to loop over the contents of a text file and do a
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I want to create a Java application bundle for Mac without using Mac. According
I want to create a client side mail creator web page. I know the
I want to reference a COM DLL in a .NET project, but I also
I want to setup a cron job to rsync a remote system to a
I want to make an etag that matches what Apache produces. How does apache
I want to log onto Stack Overflow using OpenID, but I thought I'd set
I want to open a file for reading, the C++ way. I need to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.