Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 4E

Write a function called s to extract a portion of a character string. The function should be called as follows:

s

where S is the character string from which you are extracting the substring, S is an index number into S indicating the first character of the S, c is the number of characters to be extracted from the S string, and r is an array of characters that is to contain the extracted substring.

For example, the call

s

extracts the substring̎ (three characters starting with character number 4) from the string̎ and places the result in r.

Be certain the function inserts a null character at the end of the substring in the result array. Also, have the function check that the requested number of characters does, in fact, exist m the string. If this is not the case, have the function end the substring when it reaches the end of the source string. So, for example, a call such as

s

should just place the string “words” inside the result array, even though 20 characters were requested by the call.

Blurred answer
Students have asked these similar questions
Write a function is ordered that takes an integer array and its size as parameters and returns true if the array elements are ordered in nondecreasing order and returns false if not. For example, integers in {10,0,1,1,5,1009} are ordered in nondecreasing order. On the other hand, integers in {1, 2, 3, 8, 4, 19} are not since 8 > 4
Write a function to find the maximum sum of a subarray within a given array of integers. The subarray should be contiguous, meaning the elements are adjacent to each other in the array. For example, given the array [-2, 1, -3, 4, -1, 2, 1, -5, 4], the maximum sum of a subarray is 6, which corresponds to the subarray [4, -1, 2, 1]. Write a function named maxSubarraySum that takes an array of integers as input and returns the maximum sum of a subarray. Note: If all the elements in the array are negative, the function should return 0. Example: Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4] Output: 6 Input: [-1, -2, -3, -4] Output: 0 Write the maxSubarraySum function that solves this problem efficiently.
Write a function that takes two int arrays arr1 and arr2, and their size n as parameters. The functionreturns the number of elements that exist in arr1 and arr2 with indexes i1 and i2 respectively such that i1>=i2.(Example: arr1: [ 1,5,2,3,4,0,7] arr2: [0,1,3,7,4,2] then the function returns 3 ( 0,3,7) )

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Assume as known that the Vandermonde determinant V=|11...1r1r2...r3r12r22...rn2r1n1r2n1...rnn1| is nonzero if t...

Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis

The ____________ is always transparent.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

What is a parameterized constructor?

Starting out with Visual C# (4th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License