C Programming Language
C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
Question
Book Icon
Chapter 2, Problem 5E
Program Plan Intro

Program Plan-

  • Initialize the header files and main() function.
  • Ask the user to enter the two strings.
  • To define the function any(char[], char[]) to find the position of string2 in string1.
  • Finally prints the position.

Summary Introduction- The program takes two input string and finds out the position of string2 in string1.

Program Description- The purpose of the program is to take two input strings namely string1 and string2 and print the position of string2 in string1 by using the fullowing function-

any(s1, s2).

Blurred answer
Students have asked these similar questions
C Program Functions using Pointers Create a function modify that accepts an integer and divides the integer by 2 if it is even. If the integer is odd, add one and divide it by 2. The function does not return anything.  In the main function, write a program that asks for an integer input and call the modify function by passing in the reference of that variable as a parameter.   An initial code is provided for you. Just fill in the blanks. Input 1. One line containing an integer input Output Enter a number: 5 Before: 5 After: 3
Write a c++ program: NOTE: Pointers must be used to solve the following problem. Write a function createPassword()with no return value to randomly select 8 capital letters from the alphabet. The function receives the address of the first characters of the password string as parameter. Hint:Declare a characters string that contains all the capital letters of the alphabet and use the index values of the characters in the string for random selection of characters, e.g. 5char alpha [27] = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;char *pAlpha = alpha; Display the password from the main()function.Write a function replaceVowels()with no return value to replace all the vowels (A, E, I, O, U) that have been selected with a symbol from the list ($ % @ # &). That is, A must be replaced by $, E replaced by %, I must be replaced by @, O replaced by #, and U must be replaced by &. The function receives the address of the first characters of the password string as parameter. Display the password again…
Write a user-defined function that compares two string with each other. If first one is equal to second returns 0, greater than second returns 1 and less than second returns -1. Your function prototype is int compareString(char *, char *) Write another user-defined function which gets a pointer to a character string containing the name of months. Function will return the name of month depending on its arguments. For example : if it gets 2 it will return February. if it gets O it will return incorrect month if it gets 9 it will return September Your function prototype is char "month_name(int n) Write a main function to test your functions. Do not use library functions to compare two strings. Example Input: Ankara Antalya 4 Example Output: -1 April
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr