Saturday, February 12, 2011

String Copy Example in C : How to Use strcpy()

This is simple c program for beginners that how to use strcpy function in c to copy the one string into another string. This is simple inbuilt function and pass the target string as first parameter and source string as second parameter.

 

#include <stdio.h>
#include <string.h>
#include <conio.h>

int main ()
{
  char s1[]="India Watch: C Programming";
  char s2[100];
  strcpy (s2,s1);
  printf ("s1: %s\ns2: %s\n",s1,s2);
  getch();
  return 0;
}

//Copy string example
//output
//s1: India Watch: C Programming
//s2: India Watch: C Programming

No comments:

Post a Comment

Sponsored Ad

My Blog List