I have a problem I want to copy an array to another one .. have any one any idea about this ... ?
I have a problem I want to copy an array to another one .. have any one any idea about this ... ?
Use a for loop.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Sounds like a school project.
Why do you ask? What seems to be the problem you are having that you believe you need to do this? Can you post some code?
Last edited by Syndacate; 07-30-2011 at 04:11 AM.
You can copy the contents of one array into another using memcpy or memmove. (Use memmove if the boundaries of both arrays overlap).
man page: memcpy
An example:
Code:#include <string.h> int main(void) { int src[] = { 20, 30, 40, 50, 60, 70, 80, 90 }; int dest[sizeof src / sizeof src[0]]; memcpy(dest, src, sizeof dest); return 0; }
Please review this board's homework policy ...
--> Click the red text --> Announcements - General Programming Boards
We do not as a rule simply give people answers. When it is a school assignment the general requirement is that they should start the programming on their own and come here only if they are stuck (real stuck, not lazy stuck). You do nobody any good service by simply handing out answers; the handout neither teaches them to think about the process nor enjoins them to learn more about programming.
Old saying: "Give a man a fish and you've fed him for one day. Teach a man how to catch fish and you've fed his village for a lifetime."
Be a teacher, not a cheater!