C++ Program:
#include <iostream>
using namespace std;
//Function that checks whether first string is a
substring of another string
bool isSubstring(string str1, string str2)
{
int s1Len = str1.length();
int s2Len = str2.length();
int i, j;
// Iterating over string
for (i = 0; i <= s2Len - s1Len; i++)
{
// Checking pattern
for (j = 0; j < s1Len; j++)
{
//Comparing strings
if (str2[i + j] != str1[j])
break;
}
//Checking length
if (j == s1Len)
return true;
}
return false;
}
int main()
{
isSubstring("pl", "apple")?cout << "True"<<
endl:cout<<"False" << endl;
return 0;
}
______________________________________________________________________________________________
Sample Run:

c++ How do I search for a specific string in a word? For example, when I...
I have one method {search()} that search for a particular file in a directory that the filename start by "B" and it will return the files. I have 2 file that start by B [Bcc.txt, Ba.txt]. But in main method I want to count a word "light" how many times it appeares in the each files [Bcc.txt, Ba.txt]. However, I really don't know how to do it. I need help on that. public class CountWord { public static void main(String[]...
write a program which include a class containing an array of words (strings).The program will search the array for a specific word. if it finds the word:it will return a true value.if the array does not contain the word. it will return a false value. enhancements: make the array off words dynamic, so that the use is prompter to enter the list of words. make the word searcher for dynamic, so that a different word can be searched for each...
How do I write a C program that finds how many times a word is used in a string and prints the result. The string is hardcoded. How do I also make it print the hashes? For instance: String: " Dog Cat Owl Ferret Rabbit Cat Dolphin Penguin Cat" Word 1: Owl Word 2: Cat Desired Output: Owl- 1 time(s) Cat: 3 time(s) Owl- # Cat-###
how do i return and array of string (2d array) from a single linkedlist in c? for example i have a linkedlist that contains cat->dog->dish how do i return them to main as an array (cat,dog,dish)
Hi I how do i use a vector to search a array for a string that user has enter into the console. here is some of the instructions for the programing I am trying to work on The purpose of this program is to write a class whose job is to read up to 10,000 names into a string array. The class sorts the names and then the user can ask the class to find full names containing a name...
C++ PART B: (STRING) – 40% Program Description: Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should read and display each word with the count of vowels in each word. For example : The 1 Friend 2 Wrote 2 Write functions to process and display the results. No non-constant global variables should...
How do i make a recursive binary search that compares two String arrays in java?
C convert string to binary hi I want to convert a string into binary and return it or print it. how do I do that
C++ - How can I implement this function so that it uses smart pointers to release any dynamically allocated memory when member variables are destroyed? I want to use unique_ptr to do this. bool CompactStringSet::insert(const std::string& value) { Node* cur = &this->root_; // Start at the dummy "root" node. for (auto character : value) { // For each character... Node* search = this->FindNext( cur, character); // ... find a child containing the character. if (search) { // If such a...
I am trying to make a word guessing game on java, where there are four letters and you have 10 guesses to try and guess the letter combination. When I try to play, it says every combination of letters I enter is correct. For example: "You have 10 guesses left. Enter your guess: wxyz There are 4 correct letter placements. Congrats!" I emailed my professor and she said one of my methods is wrong because I'm only checking for specific...