String
Source Code to Print out the Length of a String in C Programming
The following source code will print out the length of a string in C Programming
#include <stdio.h>
main()
{ char s[81];
printf("Enter string: ");
scanf("%s", s);
printf("length = %d\n", len(s));
}
int len(char s[])
{ if(*s)
return 1+len(++s);
return 0;
}
String Replace Function in C#
The following code will replace a character or a word with some other character or a word. This is accomplished by the replace function in C#.
using System;
using System.Text.RegularExpressions;
string strReplace;
strReplace = "This is a test string.";
strReplace = Regex.Replace(strReplace, " is", " was");
