Diaplay string using write() function .
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char * str1="c++";
char * str2="progamming";
int m=strlen(str1);
int n=strlen(str2);
for (int i = 0; i < n; i++)
{
cout.write(str2,i);
cout<<""<<endl;
}
for (int i = n; i > 0; i--)
{
cout.write(str2,i);
cout<<""<<endl;
}
// concertinateing the string
cout.write(str1,m).write(str2,n);
cout<<"\n"<<endl;
cout.write(str1,5);
}
output :
p
pr
pro
prog
proga
progam
progamm
progammi
progammin
progamming
progammin
progammi
progamm
progam
proga
prog
pro
pr
p
c++progamming
c++p
Comments
Post a Comment