Question: *************************Hello, I am having trouble with Question 3 for the funtion strcpy with pointer parameters. I renamed the strcpy funtion on my code to strcopy
*************************Hello, I am having trouble with Question 3 for the funtion strcpy with pointer parameters. I renamed the strcpy funtion on my code to strcopy because I need them to run in the same main().I feel the problem is with my code is the declaration of the pointer, but feel feer to make any changes. below is what I have so far. Thank you in advance.*****************************************************

#include
using namespace std;
unsigned int strlen(const char s[]) { unsigned int n;
for (n = 0; s[n]; n++); // same as s[n] != '\0'
return n; }
unsigned int strleng(const char * s) { unsigned int n;
for (n = 0; *(s+n); n++);
return n; } void strcpy(char t[], const char s[]) { for (int i = 0; t[i] = s[i]; i++); }
void strcopy(char * t, const char * s) { for ( ; *t++ = *s++; ); }
main() { int length_array, length_pointer; char length_of_array1[]="goingtobeontime"; char length_of_array2[15]; char* length_of_pointer1=length_of_array1; char* length_of_pointer2; strcpy(length_of_array2, length_of_array1); strcopy(length_of_pointer2, length_of_pointer1); length_array=strlen(length_of_array1); length_pointer=strleng(length_of_pointer1); cout
return 0; }
CSE 202 Lab 3 1. Perforn the following exercises under lab3 sub directory 2. IHere is stlen) function which returns the length of a null-erminated character-ray: unsigred int strleniconst char s[]) unsigned int n; for (n-a; s[n]; n?:); // same as s[n] I- '\@. return n Here is the same function using pointers: unsigned int strlenconst char s un signed for (n- return n int n; x(s+n); n++); , Write your own main() to test the correctness ofbot versions of this function. 3. Herc is stcpy) function which copics onc null-terminated char-array to another. Notc targct char-array must have cnough space to accommodate the sourcc void strcpy(char tl, const char s[]) for (1nt 1 = 0; t[1] = s[1]; 1++); Here is the same function using pointers: void strcpy(char t, const char s) for ( ; wt++ - 's++ ; ); Modify your nain) to test the correctness of both versions of this fnction as well. 8:56 AM Type here to search 4/25/2018
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
