Hi.. I am learning C using Def c++. I struck at strcpy command. It giving error for a small exercise

      char string[20];
      strcpy("Hello", string); 
      printf("%s", string);

it giving error:
`strcpy' undeclared (first use this function)

Please help me that what can i do in dev c++ to get rid of this problem

you also need to include string.h header file, like you did stdio.h header file.

>>what can i do in dev c++
First, stop using that old, obsolete compiler. Download free Code::Blocks with MinGW (they are free).

Reread how strcpy() statement is formed.

Also, see this.

As waltp said reread the syntax of strcpy(). It should be like this.


strcpy( /*character array which will hold the text after copying */ , /*string that is to be copied into another array*/ ) ;

commented: Stop downvoting people WaltP! You are so mean. He was just trying to help! +0
commented: I could have told him that -- I wanted him to look it up -4

i think hidder files are missing
include the sdtlib.h file.
might work.

commented: Do not post if you have no idea what you're talking about! -4

Thanks guys..
Thank your very much.....
specially for ancient dragon for solving my problem

i think hidder files are missing
include the sdtlib.h file.
might work.

No it won't. strcpy() is declared in string.h

add string.h library

I don't know how many times this has to be said. BTW string.h is NOT a library!

I can't believe nobody mentioned that you need to include string.h. :icon_rolleyes:


Narue -- your avatar is quite appropriate to that comment :)