i had a thought to write a program to play boggle.
i already know how it works and decide to use a heap-based method.
However, i just dont know how to write a basic step: look up a word in a dictionary.
So,if i have a word "program", how can i search it in the dictionary?
i suppose i need a dictionary file. what does this file look like and how can i use it in the
program?(how to write the code).
conan19870619
0
Newbie Poster
Recommended Answers
Jump to PostA dictionary is like any other file.
You read it in using fstreams.
Jump to PostHow is your dictionary stored? If, like iamthwee suggests, it is a file with words in it, you can just search the file for the given word.
You can even use the STL for that:
#include <algorithm> #include <fstream> #include <iterator> #include <string> // findword() // …
Jump to PostYes Duoas' example certainly has all the bows and whistles, but you can make it considerably simpler if you wish.
Google file I/O with c++.
You can do this by reading in the file just once.- Think of the boggle grid as one large set …
Jump to PostHeh heh heh -- I couldn't resist iamthwee's challenge (sorry conan --look below for where to get a dictionary).
// boggle-solver.cpp // Copyright (c) 2008 Michael Thomas Greer // <http://www.boost.org/LICENSE_1_0.txt> …
All 15 Replies

iamthwee
Duoas
1,025
Postaholic
Featured Poster

iamthwee
Duoas
1,025
Postaholic
Featured Poster

iamthwee
Duoas
1,025
Postaholic
Featured Poster
Duoas
1,025
Postaholic
Featured Poster
iamthwee
commented:
I challenge you to solve Riemann's Hypothesis next.
+15

iamthwee
Duoas
1,025
Postaholic
Featured Poster

iamthwee
Duoas
1,025
Postaholic
Featured Poster

iamthwee
Duoas
1,025
Postaholic
Featured Poster
conan19870619
0
Newbie Poster
Duoas
1,025
Postaholic
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.