Demonstrates passing an array to a function. - C Function

C examples for Function:Function Parameter

Description

Demonstrates passing an array to a function.

Demo Code

#include <stdio.h>
#include <string.h>

void change(char name[15]) // Recieves the value of i
{
    // Change the string stored at the address pointed to by name

    strcpy(name, "111111 1111111");

    return; // Returns to main
}

int main(){//  ww w. j a v a  2  s  .  c o m
    char name[15] = "test test test";

    change(name);

    printf("Back in main(), the name is now %s.\n", name);

    return(0); // Ends the program
}

Related Tutorials