Program for strlen function in string function

 Program for strlen funtion:

#include<iostream>

#include<cstring>

using namespace std;

int main()

{

char str[10]="HELLO";

char str2[100]="world";

char str3[20];

int len;

strcpy(str3,str);

cout<<"\nstrcpy(str3,str) : "<<str3;

strcpy(str, str2);

cout<<"\nstrcpy(str, str2): "<<str;

len=strlen(str);

cout<<"\nthe lenghth of "<<str<<" is "<<len;

}

output:

strcpy(str3,str) : HELLO

strcpy(str, str2): world

the lenghth of world is 5



Comments