-
Character Array copying
Hi,
Many thanks to hk_mp5kpdw for answering my previous post, was perfect thanks!
Since this is a different problem I figured a different topic would be wise, this time it should be fairly simple. Ive simply forgotten how to make one character array equal to another
eg
Code:
char name[20];
char tname[20];
tname = name;
I need tname to become equal to name as I am passing it to another function, but I cant find the lecture we had on this.
Thanks
-Steve
Edit- sorry, I have a scanf to take a value for name before I reach tname = name and tname should be empty.
-
-
-
two methods
hi there
you can use two methods for this
1. as our dear friend notified, use
Code:
strcpy(tname,name);
else
Code:
int i;
for(i=0;i<20;i++)
{
tname[i]=name[i];
}
:cool:
-
And there is also memcpy...