Hi
As JRoosh says you will have to implement the library file for strings- which is <string.h>- this library contains various functions which can manipulate char strings- because you have omitted this your compiler recognises strcpy as just another variable. What you are trying to acheive is to copy the second argument in the function to the first argument- You have not declared the second variable string-
In your example code above you neither define the string or declare it as a variable. To copy the second string to the first you must give it a value as described below.
You will have to declare variable string and then either intialize it with whatever or have user input a string..as follows
Code:
/*FIRST ROUTINE*/
#include <stdio.h>
#include <string.h>
int main (void)
{
char varname[10], string[]="Hello You";
strcpy(varname, string);
printf("%s", varname);
/*this prints Hello You to display*/
}
/*2ND ROUTINE*/
#include <stdio.h>
#include <string.h>
int main (void)
{
char varname[10], string[10];
printf("\nEnter a string up to nine characters");
gets(string);
strcpy(varname, string);
printf("\n %s", varname);
/*this prints whatever user enters to the display*/
}