I don't know what is wrong with this.
For example, I got "Hello World" in .txt file. I type "Hello" in the edit control then click the button. I got something wrong in the comment bellow. I compare this in the code:
Tab[0] // "Hello"
with
WordToFind // "Hello"
and condition is false... I don't get it
here is the code :
Code
HANDLE h;
HWND Liste;
char C;
char Val2 [250] = {0};
DWORD NbCarac =1;
int i = 0, j = 0;
char Val [30];
char Tab [25] [12] = {0};
char Trouve [10];
char WordToFind [15];
bool WordFound = false;
GetDlgItemText(hDlg, IDC_FILE, Val, 30);
GetDlgItemText(hDlg, IDC_WORD, WordToFind, 15);
h = CreateFile(Val, GENERIC_ALL, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
Liste = GetDlgItem(hDlg, IDC_Liste);
while (NbCaracLu != NULL)
{
if (!ReadFile(h, &C, 1, &NbCarac, NULL))
{
int Nb = GetLastError();
sprintf(Val2, "Error", "%d", Nb);
MessageBox(NULL, Val2, NULL, MB_OK);
}
else
{
if (C == 32)
{
Tab [j] [i] = '\0';
i = 0;
j++;
}
else
{
Tab [j] [i] = C;
i++;
}
}
}
CloseHandle(h);
Tab [j] [i] = '\0';
j = 0;
while (j < 25 && Tab [j] != NULL && !WordFound )
{
if (Tab [j] == WordToFind) //False if Tab[j] ="Hello" and WordToFind = "Hello" ... I dont get it
{
WordFound == true;
}
else
{
j++;
}
}
if WordFound == true)
{
MessageBox(NULL, "Found", NULL, MB_OK);
}
else
{
MessageBox(NULL, "Not Found", NULL, MB_OK);
}