// ----------------------------------------------
// Name: William Rennie
// Program:
// Description:
// ----------------------------------------------
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
using namespace std;
// ----------- Function definitions -------------
void printTitle(int gamenumber){
gamenumber++;
cout<<"***Word guessing game round "<<gamenumber;}
bool checkWord(char word[],char guess[]){
int i;
int x=strcmp(word,guess);
if (x==0){return true;}
else return false;
}
int main()
{
// -------- Constant declarations --------
// -------- Variable declarations --------
char wordone[4];
char wordtwo[4];
int i;
int x;
bool wordcheck;
//--------Main Program Body----------
cout <<"********"<<endl<<endl;
for (i=0;i<4;i++){
cin>>wordone[i];}
cout<<"word 2: "<<endl;
for (i=0;i<4;i++){
cin>>wordtwo[i];}
wordcheck=checkWord(wordone,wordtwo);
cout<<checkWord(wordone,wordtwo);
if (wordcheck){cout<<"t";}
else{cout<<"f";}
cout << endl << endl;
system("PAUSE"); // Pause the output window for reading
return 0;
}
it always returns 0 even when i enter the same words and im not understanding why. Is it a problem with the function itself or just how im getting the elements of the array?
also note this is just part of a game guessing program so dont mind the printtitle function thanks!