C Compiler. Standard Template Library. Python Python Tutorial. Python Programs. Python How Tos. Numpy Module. Matplotlib Module. Tkinter Module. Network Programming with Python. Learn Web Scraping. More in Python Python Compiler.
Java Core Java Tutorial. Java Type Conversion Examples. Java Wrapper Class. Java 8. Java More in Java Java Compiler. Computer Sci. Computer Architecture. Computer Network. Database DBMS. Learn SQL. Practice SQL. More Tutorials Game Development. GO Language. GIT Guide. Linux Guide. To copy string in C programming, you have to ask from user to enter the string to store it in first string variable say str1 and then copy it into the second string variable say str2 using the strcpy function of string.
The function strcpy takes two argument. The value of second argument gets copied to first argument. As the above program was written in Code::Blocks IDE, therefore after successful build and run, here is the first screenshot of the sample run that you will also see on your output screen after running the program:. This is the second snapshot of the sample run:. As you can see from previous program, I've used gets function to get the string input. Because if we use scanf function and user enters the string that contains spaces, then after space all the string's values gets skipped.
For example, if the above program is replaced with following program:. Now let's take a sample run of the above program.
0コメント