How can I get the text input from the user and count the words i am searching [closed] - c

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am using fgets to get a sentence from the user and i am trying to get words and count on c code then print it.
Exapmle: i want to count "Hello". When the program starts user write "Hello World Hello" and then the program prints "Hello used 2 times".

You could use the scanf-function to get text input from the user; the function will put it into a char array. (You would ask the user for the sentence as well as the word you are looking for)
Then you could use the KMP-algorithm to search for the given word in the sentence and just count the times the algorithm finds your word.

Related

adding to text file without overwriting and keeping the pointer at the beginning of the file in C [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 days ago.
Improve this question
So i have a loop which itterates through this encrypted text file. It then decrypts the letter and adds that new letter to a decrypted text file. only problem is that it is backwards.
So instead of lets say "Hello my name is John", the text file looks like this "nhoJ si eman ym olleH"

C program to print vowels [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
I have declared an array of vowels and is trying to compare the input string with this vowel array to count the number of vowels. It doesn't seem working. The output seems to be the multiple of input string and 5.
How to fix this?
vowels="aeiou"

Count amount of words, characters, newlines in C [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I know it is not recommended to post code as an image, since I am getting a formatting error when trying to post code on here. Anyway, I am trying to write a simple C program to count number of words, characters, newlines using do while loop. However, the output is not as expected. Please help!
Instead of a do-while, you should try using while. Since your code starts off by checking whether a is any of your if cases, it goes to the else case, and increments the New line variable. If possible, could you share the output screen.

Converting a character into a space in C arrays [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
So lets say I have received a message that resembles the following
"L2N5*8R10!11T0A1K3Y14#4W7O6O9C12R13"
and I am expected to sort out the characters in accordance to the numbers succeeding them and change the characters that are not letters into a space. I have no problem doing the sorting out part, I am only having a trouble while trying to write a function that will change those characters into space.
The out put should be something like this
TALK NOW OR CRY
but I am getting
TALK#NOW*OR!CRY
Can anyone help me figure out what my function should look like so that I can be able to change the characters into space??
Unless you show your code, we'll only be able to guess!!
However, as a general suggestion, I would recommended, you should check each entry against isalpha(). In case you got a return value of 0, replace the entry with a .

C program to make a meaningful word from jumble words [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to make a C program to arrange a jumble word into meaningful English word.There is a file "dictionary.txt" which contains lots of jumbled words. So, i have to write a program which read the jumble word from this file and convert it into a meaningful word.
For example:-
dictionary.txt file exits a "epemaxl" word
when we provide this input, the output should come "example".
I have searched alot over internet but didnot get a suitable example according to this.
Please help me.
Thanks in advance.
One strategy can be to calculate the levenshtein distance and select the word that has the closest levenshtein distance to your jumble word.
If you are on Linux (say Debian or Ubuntu, can't tell about the rest of flavors), you could skip the making of real dictionary and just check with /usr/share/dict/ wordlist.

Resources