Results 1 to 6 of 6

Thread: Use of the strcpy() in the C++

  1. #1
    Join Date
    Jan 2010
    Posts
    19

    Use of the strcpy() in the C++

    Hello, How are you all!!! I am working in the ABC software company as a software developer. I had learned the C++ language in my college day's. I also can be familiar with the most of the functions of the C++ language. So, I want to know about the strcpy() function of the C++. I also want to know the use of the C++ language. Can anyone knows about the strcpy() function of the C++ language.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    The strcpy() in the C++

    The strcpy() function of the C++ language can be used to copy the given specified string. The strcpy() function can copies the string that can be pointed by the source of the string into an array of the string that can be pointed by the destination of the string including the character that can be null. The following can be the syntax of the strcpy() function as :
    Code:
    char * strcpy ( char * dstntn, const char * src );

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Use of the strcpy()

    The following can be the parameters of the strcpy() function of the C++ language :
    1. src : This parameter of the strcpy() function of the C++ language can contains the string that can be copied into the specified destination.
    2. dstntn : This parameter of the strcpy() function of the C++ language can contains the pointer to the destination array where the content can have to be copied.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    The strcpy()

    The program that can be mentioned below describes you that how to make the use of strcpy() function into the C++ language :
    Code:
    #include <stdio.h>
    #include <string.h>
    int main ()
    {
      char sr1[]="Sample string";
      char sr2[40];
      char sr3[40];
      strcpy (sr2,sr1);
      strcpy (sr3,"copy successful");
      printf ("sr1: %s\nsr2: %s\nsr3: %s\n",sr1,sr2,sr3);
      return 0;
    }
    The above peogram can generate the following output :
    Code:
    sr1: Sample string
    sr2: Sample string
    sr3: copy successful

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Use of the strcpy() in the C++

    I think the following points can explains you about the strcpy() function more deeply and easily :
    1. The strcpy() function can copies the characters that can be in the source string variable into the destination string variable including the null character termination.
    2. The strcpy() function can returns the value that can be a destination value.
    3. The risks can overrunning from or to, because of the strcpy() function can not performs the bounds checking.

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Use of the strcpy() in the C++

    The code of lines that can be listed below can defines you about the strcpy() function of the C++ language :
    Code:
    #include <stdio.h>
    #include <string.h>
    int main() 
    {
      char inptsr[] = "Hello";
      char *otptsr;
      otptsr = strcpy(iptsr, "World");
      printf("iptsr: %s\n", iptsr);
      printf("otptsr: %s\n", otptsr);
      return 0;
    }
    Output:
    Code:
    inptsr: World
    otptsr: World

Similar Threads

  1. Difference : strdup and strcpy
    By Adene in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 11:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,128,747.96263 seconds with 16 queries