Question

Q5. Implement a C program that includes a function that copies one string into another string. You cannot use string.h librar

No pointers please

Urgent!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

 #include <stdio.h> #define MAX_SIZE 100 // Maximum size of the string void copystring(char s1[],char s2[]); int main(int argc, char* argv[]) { char s1[MAX_SIZE]; char s2[MAX_SIZE]; /* Input string from user */ printf("Please enter a string: "); scanf("%[^\n]",s1); copystring(s1,s2); printf("String 1 is copied to String 2 \n"); printf("String 1 is %s and String 2 is %s \n",s1,s2); return 0; } void copystring(char s1[],char s2[]) {          int i;                  /* Copy s1 to s2 character by character */ for(i=0; s1[i]!='\0'; i++) { s2[i] = s1[i]; } //Makes sure that the string is NULL terminated s2[i] = '\0'; }

#include <stdio.h> #define MAX_SIZE 100 // Maximum size of the string void copystring(char s1[], char 52[]); int main(int argUntitledl.c 10 11 12 13 14 15 16 17 /* Input string from user */ printf(Please enter a string: ); scanf(%[^\n], s1); copy1 2 O x Untitledl.c #include <stdio.h> #define MAX 2+2 SA 3 C:\Users\Admin\Documents\Untitled1.exe 4 void copystPlease enter

Please do like

Thanks

Add a comment
Know the answer?
Add Answer to:
No pointers please Urgent!!! Q5. Implement a C program that includes a function that copies one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This program needs to be written in C. Please use pointers. Implement a function that reverses...

    This program needs to be written in C. Please use pointers. Implement a function that reverses the bits of a decimal number represented with an unsigned char. For example: f (1) ! 128; In binary: f (00000001) ! 10000000 Your function must have the following properties: (a) Name: ReverseBits (b) Return type: unsigned char (c) Input: unsigned char

  • Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[],...

    Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[], char destination[], int n); This function copies string source to string destination. Parameter n represents the size of array destination. If the latter array is not sufficiently large to hold the whole source string then only the prefix of the string which has room in the latter array should be copied. Note that after copying, the null character should also be included to mark...

  • C++. Write a program that copies the contents of one array into another array but in...

    C++. Write a program that copies the contents of one array into another array but in reverse order using pointers.           - in main()                    - define 2 arrays of type int, 10 elements each                              - initialize one array with numbers 1 through 10                              - initialize all elements of the second array to 0                    - call function reverseCopy with both arrays as arguments                    - display the values of array number 2 (reversed order)           - reverseCopy...

  • In C Programming Language In this lab you will implement 4 string functions, two using array...

    In C Programming Language In this lab you will implement 4 string functions, two using array notation and two using pointers. The functions must have the signatures given below. You may not use any C library string functions. The functions are 1. int my strlen (char s ) - This function returns the number of characters in a string. You should use array notation for this function. 2. int my strcpy (char s [], char t I)- This function overwrites...

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • C Language program. Please follow the instructions given. Must use functions, pointers, and File I/O. Thank...

    C Language program. Please follow the instructions given. Must use functions, pointers, and File I/O. Thank you. Use the given function to create the program shown in the sample run. Your program should find the name of the file that is always given after the word filename (see the command line in the sample run), open the file and print to screen the contents. The type of info held in the file is noted by the word after the filename:...

  • 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...

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • Please, please help with C program. This is a longer program, so take your time. But...

    Please, please help with C program. This is a longer program, so take your time. But please make sure it meets all the requirements and runs. Here is the assignment: I appreciate any help given. Cannot use goto or system(3) function unless directed to. In this exercise you are to create a database of dogs in a file, using open, close(), read, write(), and Iseek(). Do NOT use the standard library fopen() ... calls! Be sure to follow the directions!...

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