By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,470 Members | 924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,470 IT Pros & Developers. It's quick & easy.

strcpy error

P: 1
Hi all,

I have a problem while doing strcpy

I have a charater pointer char **a; and another character array b[3]

I am copying the content of a to b

strcpy(b,a);

After copying,

when i print a , the content of a is printed.
when i print b, the content of b is blank.

what would be the problem. Couldn't understand the behaviour.
Pls help
Aug 10 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
Hi all,

I have a problem while doing strcpy

I have a charater pointer char **a; and another character array b[3]

I am copying the content of a to b

strcpy(b,a);

After copying,

when i print a , the content of a is printed.
when i print b, the content of b is blank.

what would be the problem. Couldn't understand the behaviour.
Pls help
A char** points to a thing that points to zero or more chars. A char* points to
zero or more chars. You can't copy one to the other because it most likely wouldn't
mean anything and second, starting at location p, where char** p; most likely
there will not be a zero terminated sequence of chars there and strcpy() goes
haywire on it.

kind regards,

Jos
Aug 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.