Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-02-2010
Member
 
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.
Reply With Quote
  #2  
Old 27-02-2010
Member
 
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 );
Reply With Quote
  #3  
Old 27-02-2010
Member
 
Join Date: May 2008
Posts: 2,008
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.
Reply With Quote
  #4  
Old 27-02-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
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
Reply With Quote
  #5  
Old 27-02-2010
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #6  
Old 27-02-2010
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Use of the strcpy() in the C++"
Thread Thread Starter Forum Replies Last Post
Difference : strdup and strcpy Adene Software Development 4 30-01-2010 11:20 AM


All times are GMT +5.5. The time now is 06:46 PM.