Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need this in C not C++ just C SET-151 C Programming #1 Homework: 7 String Basics Death by a thousand strings. Reading(s): Chapter(s) in

I need this in C not C++ just C

SET-151 C Programming #1

Homework: 7 String Basics Death by a thousand strings.

Reading(s): Chapter(s) in C Primer Plus 1-7, 9, 10

please use this format

// ------------------------------------------------------------------------------------------ // Name: Your name here // Class: C Programming // Abstract: Homework 1. // ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------ // Includes // ------------------------------------------------------------------------------------------ #include #include // ------------------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------ // Prototypes // ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------ // Name: main // Abstract: This is where the program starts // ------------------------------------------------------------------------------------------ void main( ) { } 

YOU CAN'T USE ANY BUILT-IN STRING FUNCTIONS.

Write a function that takes strSource as a parameter. The function will return the length of the string.

Write a subroutine that takes strDestination and strSource as parameters. The subroutine will copy the source string to the destination string.

Write a function that takes strSource and chrLetterToFind as parameters. The function will return the index of the first occurrence of the letter (case sensitive) in the string searching from left to right. Return 1 if the letter is not in the string.

Write a function that takes strSource and chrLetterToFind as parameters. The function will return the index of the first occurrence of the letter (case INsensitive) in the string searching from left to right. Return 1 if the letter is not in the string. Do NOT change the source string.

Write a subroutine that takes strDestination and strSource as parameters. The subroutine will append the source string to the end of the destination string. Assume the destination string is large enough to hold all the characters.

Write a subroutine that takes strDestination and strSource as parameters. The subroutine will copy the source string to the destination string in reverse order. Do NOT change the source string.

Write a subroutine that takes strDestination and strSource as parameters. The subroutine will copy the source string to the destination string and make the destination string all uppercase. Do NOT change the source string.

Write a subroutine that takes strDestination, strSource, intStartIndex and intLength as parameters. The subroutine will copy a substring from the source string to the destination string starting at intStartIndex and of length intLength. Do NOT change the source string.

Write a function that takes strSource as a parameter. The function will return the number of words in the string. For example the sentence Mary had a little lamb. has 5 words. Counting words is not the same thing as counting spaces. Do NOT change the source string.

Call each of the above functions from your main subroutine and display the results. For example:

void main( )

{

char strSource[ 50 ] = "I Love Star Trek";

int intLength = 0;

char strDestination[ 50 ] = "";

// Problem #1: String length

intLength = StringLength( "I Love Star Trek" );

printf( "Problem #1: String Length: %d ", intLength );

printf( " " );

// Problem #2: CopyString

CopyString( strDestination, "I Love Star Trek" );

printf( "Problem #2: CopyString: %s ", strDestination );

printf( " " );

etc

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions