I will be posting bits and pieces of my code that is relevant.

//Function Prototype
int binarySearch(char*); // Binary search of dictionary. the Function I'm passing to.

char* reverseTruncateCipher[80]; <---- variable I'm passing.

/*I have these variables stored in them
reverseTruncateCipher[0] = all
reverseTruncateCipher[1] = generalizations
reverseTruncateCipher[2] = are
reverseTruncateCipher[3] = false

also I have an int variable named "incrementer" initialized at 0*/

while(binarySearch(reverseTruncateCipher[incrementer]) >= 0)
{
    //random code here
    incrementer++;
}


/* Now here is where I have my problem. The variable I catch 
reverseTruncateCipher[incrementer] with is called searchWords.
In my binarySearch function, I did:

cout << searchWords;
system("pause");
and it printed out "all generalizations are false". Why is it sending the 
whole array when I really just want to send in one word at a time?

Can someone please help me? THANK YOU! */

Recommended Answers

All 3 Replies

I think you are misunderstanding what that function is doing. It is only printing one word at a time, but it doesn't print a '\n' after each word. do this and each word should be on its own line.
cout << searchWords << '\n';

Not with the system("pause"); there. When it pauses it still prints out the full line.

You need to post actual code, not something you just made up.

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.