#include<iostream.h> #include<string.h> #include<stdlib.h> #include<conio.h> class pgr { char a[10],b[10],c[10]; int ch; public: void show() { do { cout<<"\n1.stringlength\n2.stringcopy\n3.stringconcatanation\n4.exit"<<endl; cout<<"\nenter your chioce:\t"; cin>>ch; switch(ch) { case 1: cout<<"\nenter a sting is="; cin>>a; cout<<"\nenter b string is=\t"; cin>>b;cout<<"\nstring length a is\t"<<strlen(a); cout<<"\nstring length b is\t"<<strlen(b); break; case 2: cout<<"\nenter a sting is="; cin>>a; cout<<"\nenter b string is=\t"; cin>>b; cout<<"\nthe capied string is:\t"<<strcpy(b,a);; break; case 3: cout<<"\nenter a sting is="; cin>>a; cout<<"\nenter b string is=\t"; cin>>b; strcpy(c,b); cout<<"\nthe string concatanation:\t"<<strcat(a,c); break; case 4: exit(0); break; default: cout<<"invalued chioce"; } }while(ch<=1000); } }; void main() { clrscr(); pgr b; b.show(); }
Sunday, 7 December 2014
C++ program to perform string based operations by using switch case statement
Posted by Madan
Posted on 13:50