code for copying two strings with out strcpy() function.
Answer Posted / reachhary
well, we could also have a string accepted at run time by
use of scanf.
To take care of such cases.
char *mystrcpy(char src[])
{
char *dest = NULL;
int indx = 0, len = 0;
if (!src) return dest;
len = strlen(src);
dest = (char *)malloc(sizeof(char) * len + 1);
while (; src[indx] ; dest[indx++]=src[indx]);
dest[indx]='\0'
return (dest)
}
Please do update if any one finds any issue with the code
segment - in terms of any error or any optimisation
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
which is conditional construct a) if statement b) switch statement c) while/for d) goto
What are global variables and how do you declare them?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.
can any one tel me wt is the question pattern for NIC exam
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
Explain how to reverse singly link list.
Why main is used in c?
What is the difference between scanf and fscanf?
What is the auto keyword good for?
How to establish connection with oracle database software from c language?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
Why main is not a keyword in c?
Write a program to swap two numbers without using a temporary variable?