Home > Programming > Functions using the "C" programming language > example17.c

 

Previous

Next


/*
    In this example we demonstrate how to use strings as function parameters.
*/

#include <stdio.h>
#include <conio.h>

/* Function prototype, takes as parameter an array of characters */

void print_str( char [] );

void main()
{
    char s1[24] = "This is a fixed string.";
    char *s2 = "This is not a fixed string.";
/* We call function print_str with parameter an array of characters.*/
    print_str( s1 );
/* We call function print_str with parameter a pointer.*/
    print_str( s2 );
/* We call function print_str with parameter a constant string.*/
    print_str( "This is a constant string." );
    getch();
}

void print_str( char s[] )
{
    printf( "%s\n", s );
}


© 2004 Jim Valavanis

Previous

Next

1