by Dinesh Thakur Category: Functions

strcpy () : If Sl and S2 are the names of two strings, the function call strcpy (S1, S2) copies

the contents of S2 including null character on to Sl. If S2 is smaller than Sl, there is no problem, however, if S2 is bigger than Sl the operation will eat into adjacent memory.

#include<conio.h>
#include<string.h>
#include<iostream.h>
char name[30]; // First name of Someone
void main()
{
      clrscr();
      strcpy(name, "Dinesh"); // Initialize the Name
      cout<<"The name is : "<< name<<"\n";
      getch();
}

How To Use Strcpy (String Copy)



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles