0

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

#include<stdio.h>
main()
{
      char string[20];
      
      strcpy("Hello", string); 
      
      printf("%s", string);
      fflush(stdin);
      getchar();
      }

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

Edited by Narue: Added cide tags

7
Contributors
10
Replies
13
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

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).

Edited by Ancient Dragon: n/a

1

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

strcpy(string,"HELLO");

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

Edited by Arbus: n/a

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

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

Votes + Comments
Do not post if you have no idea what you're talking about!
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.