473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How does strcpy function work

1
HOW DOES STRCPY WORKS ? why do we need it ?
May 15 '07 #1
3 9104
JosAH
11,448 Expert 8TB
HOW DOES STRCPY WORKS ? why do we need it ?
Basically the strcpy() function works like this:
Expand|Select|Wrap|Line Numbers
  1. char* strcpy(char* dst, char* src) {
  2.    char* ret;
  3.    for(ret= dst; *dst++= *src++; );
  4.    return ret;
  5. }
... and we need it for copying C '\0' terminated char arrays.

kind regards,

Jos
May 15 '07 #2
AdrianH
1,251 Expert 1GB
HOW DOES STRCPY WORKS ? why do we need it ?
HUH? CAN YOU YELL ANY LOUDER!?!?!

It is impolite to type in uppercase. It implies that you are yelling. ;)


Adrian
May 15 '07 #3
take a look to find more:

http://www.cplusplus.com/reference/clibrary/cstring/strcpy.html
May 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Paul Sheer | last post by:
I need to automatically search and replace all fixed size buffer strcpy's with strncpy's (or better yet, strlcpy's) as a security and stability audit. The code base is large and it is not feasable...
9
by: Ape Ricket | last post by:
Hi. During my program's set-up phase where it reads in the arguments it was invoked with, I programmed this: if (strcmp(argv,"-G") ==0) { geom_scaling = ON; if (i < argc-1)...
17
by: Grant Austin | last post by:
I have a linked list where each node holds a couple numbers a char and a const char array. I use strcpy to take an char array argument passed to my insert function to copy the string into the new...
4
by: Tony Johansson | last post by:
Hello!! I have done some operator overloading but my main testprogram doesn't work well. Have you any idea which of my methods are wrong? #include <iostream> #include <string> using...
3
by: kaizen | last post by:
Hi, i wrote the code in C and compiled in VC++ compiler. at that time it has thrown the below mentioned error. error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'...
38
by: edu.mvk | last post by:
Hi I am using strcpy() in my code for copying a string to another string. i am using static char arrays. for the first time it is exected correctly but the second time the control reaches...
3
by: RavindraB | last post by:
I am migrating C++ code to VS2005, for this i have to replace the some Deprecated CRT Functions like “strcpy” by strcpy_s I have written template to replace the function call. For strcpy_s I need...
15
by: Alok Kumar | last post by:
#include <string.h> void myfn() { char a = 'A'; char b; strcpy(b, &a); } Would I always get 'A' in b and '\0' in b after the strcpy?
8
by: aarklon | last post by:
Hi all, why #include<stdio.h> #include<stdlib.h> #include<string.h> int main(void)
77
by: arnuld | last post by:
I have created my own implementation of strcpy library function. I would like to have comments for improvements: /* My version of "strcpy - a C Library Function */ #include <stdio.h>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.