C program to copy a string using strcpy function




















C Language C Tutorial. 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. The strcpy function is used to copy strings. It copies string pointed to by source into the destination. This function accepts two arguments of type pointer to char or array of characters and returns a pointer to the first string i.

Notice that source is preceded by the const modifier because strcpy function is not allowed to change the source string. It is important to note that strcpy function do not check whether the destination has enough size to store all the characters present in the source. It is the responsibility of the program to make sure that the destination array has enough space to accommodate all the characters of the source string. Another important point to note about strcpy is that you should never pass string literals as a first argument.

For example:.



0コメント

  • 1000 / 1000