Replacing a substring in a string using memset() C function


Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows 2003 Server Standard Edition

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)

Other info:

To do: Replacing a substring in a given string using memset() C function

To show: Using the memset() C function to replace a substring in the given string





// Using memset()

#include <stdio.h>

#include <string.h>


int main(void)




printf("Using memset()\n");


printf("string = %s\n", string);

printf("string after memset(string, 'b', 15) =\n%s\n", memset(string, 'b', 15));

return 0;



Output example:


Using memset()



string after memset(string, 'b', 15) =


Press any key to continue . . .



C and C++ Programming Resources | C & C++ Code Example Index