step 2:declare a,b as character array
step 3:enter b
step 4:print “authentic string”,b
step 5:carry out strcpy() operation
step 6:print “copied string”,a
printf(“Enter a String:”);
Pattern Enter and Output
Enter a String:Mumbai
Clarification of above program
In above Program we’re copying one string and storing it into one other utilizing strcpy() perform
the strcpy() perform is a normal library perform in C/C++.
Parameters related to strcpy()
supply:supply factors to the variable the place the string that’s to be copied is saved.
vacation spot:It factors to the variable during which the string goes to be copied.
The perform of strcpy() perform is solely copying the content material of supply variable into vacation spot variable.
Let’s perceive line by line
datatype created utilizing construction and union).Within the subsequent line of code we’re declaring two array of character,it’ll act as a string not directly as a result of string is nothing however an array of character.
Within the subsequent line of code,we’re merely printing the message “Enter a string” after which we’re taking enter in string format utilizing will get() perform
this perform is used to take enter in string format and retailer the end result within the given variable which is handed in will get() perform.The will get() and places() are declared within the header file stdio.h. Each the
features are concerned within the enter/output operations of the strings.This perform allows the person to enter some character adopted by the enter key.
Within the subsequent line of code,we’ve got written ‘ “Authentic String:”%s,b’ On this Line the primary a part of line is inside double code which will likely be printed as it’s As we’ve got realized that every one the assertion that are enclosed inside double quotes will we printed as it’s,after that we’ve got put %s in printf() perform,right here %s is format specifier for string variable which we’ve got talked about instantly after it i.e b variable.So lastly have been are on essentially the most import line of code i.e the place the precise operation of program is getting carried out.strcpy() perform takes two argument the primary is the place the copied string ought to be saved and the second argument from which variable string ought to be copied.
In the event you any have doubt,suggestion relating to this put up or web site then be at liberty to share with us.
In case you have realized one thing new from this put up then share this put up with your loved ones and
Completely happy Studying :)😎