Copying Strings terminated by \0, C char array based string - C++ Data Type

C++ examples for Data Type:char array

Introduction

The strcpy_s() function copies the entire contents of one string into a designated buffer.

Demo Code

#include <iostream> 
#include <string.h> 

int main() /*from   w  w w.j  a  va2 s  .  c o  m*/
{ 
    char string1[] = "Free the bound periodicals!"; 
    char string2[80]; 

    strcpy_s(string2, string1); 

    std::cout << "String1: " << string1 << std::endl; 
    std::cout << "String2: " << string2 << std::endl; 
    return 0; 
}

Result


Related Tutorials