1

I want to assign a string like: "22 33" to a variable like char*av[129]. How can i do that in C/C++?

1
  • 4
    those types are incompatible -- a single string vs. an array of strings. Commented Feb 19, 2012 at 6:28

1 Answer 1

3
strcpy(av[0], "22 33");

IF you know av[0] is long enough (length of string you want to put in plus one for the NUL).

Otherwise, use strncpy.

Sign up to request clarification or add additional context in comments.

1 Comment

He should always use strncpy, even only as a good habit. Also, it won't solve his problem if the buffer isn't long enough - it would just change the bug, perhaps to a friendlier one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.