0
strcpy(post[j],in[x]);

Just what is wrong with this code of mine?

in[x]='4'

But it doesn't copy the value to post[j]

4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by abhishek das
0

having all relevant code would be nice. i.e. variable declarations of post an in, and any libraries you may be using. As for the function, is it hand coded or out of a library? If it's hand coded, we'll need that as well. If it's out of a library, then it's being used incorrectly. The "str" in strcpy() implies string like this was designed for use on arrays of chars not ints. While it could be used for arrays of anything, it'll just end up really confusing if you try to use it for anything other than strings or arrays of chars.

1

strcpy() does not work with single characters -- it works with entire null-terminated character arrays. If you want to copy just a single character than simply use the = assignment operator. post[j] = in[x];

Edited by Ancient Dragon: n/a

0

@Ancient Dragon: Your explanation is what i needed. Thanks!

This question has already been answered. 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.