Question

C Question: I apologize for this long size post, but I wanted to explain the way...

C Question: I apologize for this long size post, but I wanted to explain the way of doing it. Kindly HELP me .

Question is:

implement char *mystrcat(char *dest, const char*src)  

adds a copy of the string src onto the end of the string starting at dest. The first char is src is put at the location of the 0 at the end of string dest. Returns dest

Could you please implement / write the code in the same way I have written for " *myindex(const char *s, int c) "

I made 2 files, name: mn3.c and my3.c for *myindex(const char *s, int c) . Please make same kind of 2 files, you cane give name like mn2.c & my2.c ( Or anything you want). There kindly implement char *mystrcat(char *dest, const char*src)

It adds a copy of the string src onto the end of the string starting at dest. The first char is src is put at the location of the 0 at the end of string dest. Returns dest.

SAMPLE CODE :

The code for mn3.c is:

#include

char * myindex(const char *s, int c);

int main()
{
//char *str = "dogcat";
char str[] = "dogcat";
char *p = myindex(str, 'X');
if (p!=0) printf("%d\n", p-str);
else printf("Not Found\n");

p = myindex(str, 'c');
if (p!=0) printf("%d\n", p-str);
else printf("Not Found\n");

*p = 'X';
printf(str);
}

And the code for my3.c is:

char * myindex(const char *s, int c)
{
while (*s !=0) {
if (*s==c)
return (char *) s; //(char *) is a cast
s++;
}
return 0;
}

char * myrindex(const char *s, int c)
{
char *r=0;
while (*s !=0) {
if (*s==c)
r=s;
s++;
}
return r;

}

Above- I made 2 files, name: mn3.c and my3.c for *myindex(const char *s, int c) . Please make same kind of 2 files, you cane give name like mn2.c & my2.c ( Or anything you want). There kindly implement char *mystrcat(char *dest, const char*src)  

adds a copy of the string src onto the end of the string starting at dest. The first char is src is put at the location of the 0 at the end of string dest. Returns dest

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
C Question: I apologize for this long size post, but I wanted to explain the way...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • C++ When running my tests for my char constructor the assertion is coming back false and...

    C++ When running my tests for my char constructor the assertion is coming back false and when printing the string garbage is printing that is different everytime but i dont know where it is wrong Requirements: You CANNOT use the C++ standard string or any other libraries for this assignment, except where specified. You must use your ADT string for the later parts of the assignment. using namespace std; is stricly forbiden. As are any global using statements. Name the...

  • The following code is a C Program that is written for encrypting and decrypting a string....

    The following code is a C Program that is written for encrypting and decrypting a string. provide a full explanation of the working flow of the program. #include <stdio.h> int main() { int i, x; char str[100]; printf("\n Please enter a valid string: \t"); gets (str); printf ("\n Please choose one of the following options: \n"); printf ("1 = Encrypt the given string. \n"); printf("2 = Decrypt the entered string. \n"); scanf("%d",&x); // using switch case statements switch (x) {...

  • Write a function that can return the length of a string in C language. Please leave...

    Write a function that can return the length of a string in C language. Please leave comments to explain the code and verify that it runs properly... Example: Input String: China The length of the string is 5. #include <stdio.h> int length(char * p) {     /write your code here } main(){     int len;     char str[20];     printf("Input string:");     scanf("%s", str);     len = length(str);     printf("The length of string is %d. ", len);     getchar();    ...

  • Due to lack of time, I need help writing this c++ function and sample driver. I...

    Due to lack of time, I need help writing this c++ function and sample driver. I will add the description below. Any help would be greatly appreciated. Thank you. Write a function with two C++ strings as parameters void addS( const char origl], char plural]) The function will make a copy of orig to the C++ string The function will make a copy of orig to the C+t string plural with an 's at the end. A sample driver would...

  • Please answer problem #5 thank you str.c #include "str.h" #include <stdio.h> int str_len(...

    Please answer problem #5 thank you str.c #include "str.h" #include <stdio.h> int str_len(char *s) {    /* this is here so code compiles */ return 0; } /* array version */ /* concantenate t to the end of s; s must be big enough */ void str_cat(char s[], char t[]) {    int i, j;    i = j = 0;    while (s[i] != '\0')    /* find end of s */        i++;    while ((s[i++] = t[j++]) != '\0') /* copy t */        ;...

  • Programs 1. String Utilities In this exercise you will implement several utility functions involving strings. You...

    Programs 1. String Utilities In this exercise you will implement several utility functions involving strings. You will place all of your function prototypes in a header file named string utils.h and all of your function definitions in a source file named string utils.c. You should implement your own main test driver program to test your functions, but you need not hand it in. a. void addChar(char *str, char c, int n) - this function should add a char c at...

  • SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! myst...

    SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...

  • I am having problems with the following assignment. It is done in the c language. The...

    I am having problems with the following assignment. It is done in the c language. The code is not reading the a.txt file. The instructions are in the picture below and so is my code. It should read the a.txt file and print. The red car hit the blue car and name how many times those words appeared. Can i please get some help. Thank you. MY CODE: #include <stdio.h> #include <stdlib.h> #include <string.h> struct node { char *str; int...

  • write program in C language. To get more practice working with files, you will write several...

    write program in C language. To get more practice working with files, you will write several functions that involve operations on files. In particular, implement the following functions 1. Write a function that, given a file path/name as a string opens the file and returns its entire contents as a single string. Any endline characters should be preserved char *getFileContents (const char filePath); 2. Write a function that, given a file path/name as a string opens the file and returns...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT