Trying to copy contents of array

I am trying to copy the contents from array a to array b. When I test within the function it seems to copy, but when I print out b in the main program, it shows 0s

void array_copy(int a[], int b[], int n) {

for (int j = 0; j < n; j++) {
    b = a;
    //printf("%d\n", *b);

and then when I try and print to test outside, I get 0s

printf("%d", *b);

Any ideas why I am getting 0 instead of what should be in there. (I have made sure array a does contain non zero values)


b = a;

This line makes the pointer b points to the same place where a points to. What you want (copying the contents) should be:

*b = *a;

Need Your Help

Getting session variable in JSP page using Login Form Authentication provided by Jave EE

java jsp session java-ee login

I'm following this guide Securing web application in order to create login form authentication in my web app. Unfortunately something don't satisfy me. I'm looking for a variable that I could use i...

Navigation with Facelets template not working

jsf navigation facelets

I'm having some trouble with navigation when using Facelets.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.