top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Is there any simple way to add a char array to another array in C?

+4 votes
50 views
Is there any simple way to add a char array to another array in C?
posted Aug 13, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Can you give more clarity on your requirement ?
Say we have one array a of 5 elements and another array b of 3 elements. Now I want b should have its 3 elements followed by elements of a.

1 Answer

+1 vote

Yes you can use mem copy

memcopy(B + sizeof(char) * no of element in B, A, sizeof (char) * no of elements in A);

if A has 5 elements, B has 3 elements

Go to end of B array and do memcpy from A to B according to the number of element in A.

But make sure that for B sufficient memory is allocated.

I hope this was you requirement.

answer Aug 13, 2015 by Sachidananda Sahu
Similar Questions
+4 votes

I am wanting to extract variable names and their size (int, char and etc.) from a c file.
Is there any way to extract that type of information?

+1 vote

Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function in C programming?

+1 vote

Please help me with c program which takes less memory and time to sort a unsorted array of 1000 chars, its order should not be more then O(N) and memory should be most least as possible. Use bit fields and share the program?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...