thevampsrock3
21.04.2020 •
Chemistry
Write a C program that implements and tests the three C functions described in problems 5, 6 and 7 on page 231 of the text. Here are the prototypes:
// find second string in first
// return index where string starts or -1 if not found
int findString(char *, char *);
// remove specified number of characters starting at
// a specified index.
// first int is starting index, second is count
// if failure, do nothing
void removeString(char *, int, int);
// insert the second string into the first starting
// at the specified index
// if failure, do nothing
void insertString(char *, char *, int);
Problem 5 from page 231 stats: Write a function called findString() to determine if one character string exists inside another string. The first argument to the function should be the character string that is to be searched adn the second argument is the string you are interested in finding. If the function finds the specified string, have it return the location in the source string where the string was found. If the function does not find the string, have it return -1.
Problem 6: Write a function called removeString() to remove a specified number of characters from a character string. The function should take three arguments: The source string, the starting index number in the source string, and the number of characters to remove.
Problem 7: Write a function called insertString() to insert one character string into another string. The arguments to the function should consist of the source string, the string to be inserted, and the position in the source string where the string is to be inserted.
Specification
1. For this project, the purpose of "main" is to simply test the three functions. Do not have the user supply data to main.
2. One additional requirement beyond what is stated in the text is that square brackets "[ ]" are not allowed in any of the three functions. In other words, use pointers to access the character strings rather than array notation.
NOTE: Square brackets are fine in "main".
3. Do not use any of the (string.h) library functions within your functions. Note, you may use those functions in "main" if you like.
4. Use the exact prototypes provided above.
5. You may have as many additional functions as you like. You are not limited to these three. (these are often called helper functions or utility functions)
THE TESTER MAIN THAT WAS GIVEN IS
int main()
{
//find
printf("Found hat at %i\n", findString("chatterbox", "hat"));
printf("Found att at %i\n", findString("chatterbox", "att"));
printf("Found box at %i\n", findString("chatterbox", "box"));
printf("Found boxx at %i\n", findString("chatterbox", "boxx"));
//remove
char str3[20] = "chatterbox";
removeString(str3, 9, 1);
printf("\nAfter remove 1 = %s\n", str3);
char str4[20] = "chatterbox";
removeString(str4, 4, 5);
printf("After remove 2 = %s\n", str4);
char str5[20] = "chatterbox";
removeString(str5, 0, 7);
printf("After remove 3 = %s\n", str5);
//insert
char str8[20] = "the wrong son";
insertString(str8, "per", 14);
printf("\nAfter insert 1 = %s\n", str8);
insertString(str8, "per", 10 );
printf("After insert 2 = %s\n", str8);
insertString(str8, "You are ", 0);
printf("After insert 3 = %s\n\n", str8);
return 0;
}
Solved
Show answers
More tips
- F Family and Home How to Properly Use a Water Level?...
- D Dating, Love, Relationships 10 Useful Tips on How to Survive a Breakup?...
- F Food and Cooking Apple Cider Vinegar: The Ultimate Health and Beauty Solution...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Chemistry
- C Chemistry Provide information on characteristics like national college graduation rates. Select one: a. Inductive data b. Qualitative data c. Nonnumeric data d. Incomputable data e....
- C Chemistry True or False of the three states of matter, molecules in solids have the greatest freedom of motion....
- C Chemistry True or False gases have indefinite shapes because gas molecules are constantly changing their positions....
- C Chemistry 5. Water displacement is a method to measure ? O volume Odensity mass O temperature PKEASE HELP...
- C Chemistry The ocean floor, some parts of which get no sunlight, is the *...
- C Chemistry A student precipitates her ions out of solution, then places it in a hot water bath. After removing it from the water bath, the white precipitate disappeared. At this point,...
- C Chemistry What volume of chlorine gas at 646 torr and 32oC would be produced by the reaction of 14.75 g of MnO2 according to the following chemical equation? MnO2(s) + 4 HCl(aq) MnCl2(aq)...
- C Chemistry In an oxidation-reduction reaction, the reducing agent In an oxidation-reduction reaction, the reducing agent gains electrons and loses potential energy. loses electrons and...
- S Social Studies Every morning, my bathroom scale tells me that i weigh 120 pounds. however, when i go to the doctor, their very accurate professional scale says i weigh 130 pounds. my bathroom...
- B Business Bateman corporation sold an office building that it used in its business for $800,000. bateman bought the building 10 years ago for $600,000 and has claimed $200,000 of depreciation...
Ответ:
I’m not sure anyone can help with this problem.
Explanation:
It is too not understandable. I can’t read anything that is written only the question that is asked. My suggestion to you, is maybe try asking it again but not so much. Sorry I couldn’t help, just wanted to let you know.
Ответ: