Assign string value with strcpy - C String

C examples for String:String Function

Description

Assign string value with strcpy

Demo Code

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

#define KIDS 3//  w  w w.  j  ava2  s. c om
#define FAMILY "test test"
#define MORTGAGE_RATE 5.15

int main(){
    int age;
    char childname[14] = "Mary";
    printf("\n%s have %d kids.\n", FAMILY, KIDS);
    age = 11;
    printf("The oldest, %s, is %d.\n", childname, age);
    strcpy(childname, "Christopher");
    age = 6;
    printf("The middle boy, %s, is %d.\n", childname, age);
    age = 3;
    strcpy(childname, "Benjamin");
    printf("The youngest, %s, is %d.\n", childname, age);

    return 0;
}

Result


Related Tutorials