Using memset to copy the byte into a specified number of bytes - C++ Data Type

C++ examples for Data Type:char array

Description

Using memset to copy the byte into a specified number of bytes

Demo Code

#include <iostream> 
#include <cstring> // memset prototype 
using namespace std; 

int main() //from  w  w w . j  a va 2  s .c  om
{ 
   char string1[ 15 ] = "BBBBBBBBBBBBBB"; 

   cout << "string1 = " << string1 << endl; 
   cout << "string1 after memset = " 
       << static_cast< char * >( memset( string1, 'b', 7 ) ) << endl; 
}

Result


Related Tutorials