vividexstance's Profile User Rating: *****

Reputation: 711 Enlightened
Group:
Expert
Active Posts:
2,462 (1.62 per day)
Joined:
31-December 10
Profile Views:
13,784
Last Active:
User is online 48 minutes ago
Currently:
Viewing Forum: C and C++

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
C/C++

Latest Visitors

Icon   vividexstance has not set their status

Posts I've Made

  1. In Topic: Find String in Vector

    Posted 4 Mar 2015

    Just wondering, being as there are so many words in the dictionary, do you know what the correct results should be?
  2. In Topic: Find String in Vector

    Posted 4 Mar 2015

    I don't think you need to be looking for words based on there length. You should be using the string::find* family of functions to search for the dictionary words.

    Quick question, once a dictionary word is found, should you keep looking for it, or can you just get rid of it?
  3. In Topic: Find String in Vector

    Posted 4 Mar 2015

    I think part of your problem is that you're reversing the word maze, instead of reversing the dictionary words. Doing that would make searching easier in my opinion.

    *EDIT*:
    It's not that big deal right now, but when opening files, you should check if the file was opened correctly, especially when you're opening it for reading.

    When you open a file for writing it is automatically created, not the same for reading.

    A simple ifstream::is_open() call will check if the file was opened.
  4. In Topic: Find String in Vector

    Posted 4 Mar 2015

    Should also start your programs off small. For instance, write a small program that reads in the dictionary file and output that vector to make sure its working correctly.

    Then do the same for the other file. Once you know both of those parts of the program work, you can focus on the "real" work.
  5. In Topic: Find String in Vector

    Posted 4 Mar 2015

    I see a common mistake newcomers make when getting input from a file. Instead of checking for EOF inside the while-loop's condition. You should just put the getline() call there, because the getline() returns the istream which will fail if the stream is in an error/bad state.

    The way you're doing it right now, you could be at the end of the file, try to read a line, and then try to use that line even though nothing was read in.

    You need to get the input first, then check if the stream is in a good state. Hence why I said to put the getline in the while-loop's conditional.

    Instead of:
    while(!raghav.eof())
    {
    	getline(raghav,rag);
    	transform(rag.begin(), rag.end(), rag.begin(),::tolower);
    	forward.push_back(rag);
    	rag=string(rag.rbegin(),rag.rend());
    	reverse.push_back(rag);
    }
    
    

    You should do something like:
    while(getline(raghav,rag))
    {
    	transform(rag.begin(), rag.end(), rag.begin(),::tolower);
    	forward.push_back(rag);
    	rag=string(rag.rbegin(),rag.rend());
    	reverse.push_back(rag);
    }
    
    

    This might not fix your main problem, but its one of the problems that needs to be fixed.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Comments

Page 1 of 1
  1. Photo

    orihotomihsah Icon

    09 Sep 2013 - 09:45
    Hi
Page 1 of 1