Find a word in a word array
Lakaiz
-
[Dal] Posted messages 6122 Registration date Status Contributor Last intervention -
[Dal] Posted messages 6122 Registration date Status Contributor Last intervention -
Hello,
I am currently working on a C program to create an automatic email. I need to create a function that will find a keyword within the body of my email.
The body of my email is an array stored in a structure that I will write to a txt file.
My keyword is also in a txt file.
I think the function can be implemented by searching for spaces in my email body and comparing the characters between those spaces with my keyword to see if it is indeed in the text.
If you have any links or codes that could help me, I'd be grateful.
Thank you,
Configuration: Linux / Firefox 79.0
I am currently working on a C program to create an automatic email. I need to create a function that will find a keyword within the body of my email.
The body of my email is an array stored in a structure that I will write to a txt file.
My keyword is also in a txt file.
I think the function can be implemented by searching for spaces in my email body and comparing the characters between those spaces with my keyword to see if it is indeed in the text.
If you have any links or codes that could help me, I'd be grateful.
Thank you,
Configuration: Linux / Firefox 79.0
2 answers
-
Hello Lakaiz,
I am interested...
In C, there is a function to search for a substring within a string,
no need to look for spaces between words and compare characters:
read keyword from mots_cles.txt
read line from corps_mail.txt
search keyword in line
if not found: next line, etc ... -
Hi Lakaiz,
You should research the functionstrtok()
, which allows, through successive calls to this function, to search for sequences of characters separated by delimiter characters, such as the space character.
You will probably want to add punctuation to the delimiter characters.
Dal