Given below is the C++ program to compare two strings.
Step-by-step explanation:
C++ programming language offers various string functions such as
strcpy (s, s'): copies string s' in string s.
strcat (s, s'): concatenates strings s' to the string s that is string s' is joined to string s at its end.
strlen(s): calculates the length of the string that the number of characters including spaces in the string.
strcmp (s, s'): returns zero if strings s and s' are equal. Hence, This function is used in the below program:
#include<iostream>
#include<cstring>
using namespace std;
int main(){
- cout<< "Enter correct dictation:";
- cout<< "Enter testing dictation:";
- if(strcmp(s1, s2)==0) { cout<<"It is correct"<<endl; }
- else { cout<<"It is wrong."<<endl; } }