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]

Recommended Answers

All 4 Replies

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.

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];

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

it will not work dude
untill u specify whats dere in the arrays.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.