//creates a 10 by 10 word search puzzle
//words determined by a specified filed
//word locations then specified by user
//program creates random letters to fill in the puzzle
//programmer : Tyler Sievers
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
constint k=5; // 5 is the most words allowed in file. constant for the first array
constint r=10; //10 rows high
constint c=10; //10 collomns wide
void getfile(ifstream&);
void populatearray(ifstream&, string[]);
void testfcn1(string[]); //comment when done!!!!
void displaygrid(char[][c]);
void colomncounter();
void horizontalborders();
void fillgrid(char[][c]);
void printgrid(constchar[][c]);
void main(){
//more or less does nothing :]
ifstream infile;
string words[k];
char thegrid[r][c]; //tron reference intended... if only i were as good a programmer...
cout<<"welcome to the Word Finder Generator\n\n";
getfile(infile);
populatearray(infile, words);
//testfcn1(words); // COMMENT WHEN DONE!!!
system("CLS");
fillgrid(thegrid);
displaygrid(thegrid);
return;
}
void getfile(ifstream& words){
//gets the file name from the user, opens it, and returns to the main
string filename;
do{
cout<<"Please enter the name of the file with the word list: ";
cin >> filename;
words.open(filename.c_str());
if (words.fail())
cout << "I'm sorry, that file could not be found. Please try again.\n";
}while(words.fail());
return;
}
void populatearray(ifstream& infile, string word[])
{//takes the array words and fills it with the words from the file!!
int i; //array counter
for(i=0; i<k; i++){
infile>>word[i];}
return;
}
void testfcn1(string word[]){
//test module to be sure my fill module works correctly
// COMMENT THIS OUT WHEN DONE!!!!
int i;
for(i=0;i<k;i++){
cout<<word[i];
cout<<endl;}
return;
}
void displaygrid(constchar thegrid[][c]){
//manages all the sub modules that display and change the grid
colomncounter();
horizontalborders();
printgrid(thegrid);
horizontalborders();
colomncounter();
}
void horizontalborders(){
int i=0;
cout<<" ";
for(i=0; i<c; i++){
cout<<"---";
}
cout<<endl;
}
void colomncounter(){
int i=0;
cout<<" ";
for(i=0; i<c; i++){
cout<<i<<" ";
}
cout<<endl;
}
void fillgrid(char thegrid[][c]){
//fills the grid with .'s
int i, j; //counters
for(i=0;i<r;i++)
for(j=0;j<c;j++)
thegrid[i][j]='.';
}
void printgrid(char thegrid[][c]){
int i,j; //counters... i'm sick of this comment
for(i=0;i<r;i++){
cout<<i<<"|";
for(j=0;j<c;j++){
cout<<" "<<thegrid[i][j]<<" ";}
cout<<"|"<<i<<endl;}
}
i am getting 3 errors
Error 1 error LNK2019: unresolved external symbol "void __cdecl displaygrid(char (* const)[10])" (?displaygrid@@YAXQAY09D@Z) referenced in function _main c:\Users\Tyler\documents\visual studio 2010\Projects\program 1b-3\program 1b-3\prog_1b-3.obj program 1b-3
Error 2 error LNK2019: unresolved external symbol "void __cdecl printgrid(char const (* const)[10])" (?printgrid@@YAXQAY09$$CBD@Z) referenced in function "void __cdecl displaygrid(char const (* const)[10])" (?displaygrid@@YAXQAY09$$CBD@Z) c:\Users\Tyler\documents\visual studio 2010\Projects\program 1b-3\program 1b-3\prog_1b-3.obj program 1b-3
Error 3 error LNK1120: 2 unresolved externals c:\users\tyler\documents\visual studio 2010\Projects\program 1b-3\Debug\program 1b-3.exe program 1b-3
last night when i called it quits none of these errors came up and i can't see what could be causing them any ideas?
Your printgrid() and displaygrid() function prototypes are swapped. One takes a const char[][], and the other takes a normal char[][]. The prototypes have it the opposite way.