c++ string comparison

// C++ program to check if
// two strings are identical
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  
    char string1[100], string2[100];
  
    // Get the strings which
    // is to be checked
    cin >> string1;
    cout << "Enter the first string: " << string1;
  
    // Get the strings which
    // is to be checked
    cin >> string2;
    cout << "\nEnter the second string: " << string2;
  
    // Check if both strings are equal
    cout << "\nAre both strings same: ";
  
    if (strcmp(string1, string2) == 0)
    {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
  
    return 0;
}
  
// This code is contributed by Akanksha Rai

C++ String Compare Example

#include <iostream>  
#include <cstring>  
using namespace std;  
int main ()  
{  
  char key[] = "Softhunt.net";  
  char buffer[50];  
  do {  
     cout<<"Which is your favourite tutorial website? ";  
     cin>>buffer;  
  } while (strcmp (key,buffer) != 0);  
 cout<<"Answer is correct!!"<<endl;  
  return 0;  
}
Source: softhunt.net

compare function in c++

// CPP code for demonstrating
// string::compare (const string& str) const
 
#include<iostream>
using namespace std;
 
void compareOperation(string s1, string s2)
{
    // returns a value < 0 (s1 is smaller than s2)
    if((s1.compare(s2)) < 0)
        cout << s1 << " is smaller than " << s2 << endl;
 
    // returns 0(s1, is being compared to itself)
    if((s1.compare(s1)) == 0)
        cout << s1 << " is equal to " << s1 << endl;
    else
        cout << "Strings didn't match ";
     
}
 
// Driver Code
int main()
{
    string s1("Geeks");
    string s2("forGeeks");
    compareOperation(s1, s2);
     
    return 0;
}

C++相关代码片段

how to kill

hello world cpp

cpp hello world

when kotlin

how to write hello world c++

fenwick tree

main function

python loop

is palindrom

subsequence

insertion sort

react cookie

data structure

Stack Modified

increment integer

496. Next Greater Element I.cpp

c++ freecodecamp course 10 hours youtube

simple interest rate

deliberation meaning

fingerprint

c++ system() from variable

operator using

unambiguous

Stream Overloading

quick_sort

hash table

graph colouring

the question for me

fname from FString

how togreper

is plaindrome

logisch oder

robot framework for loop example

spyder enviroment

pallindrome string

ue4 c++ string from fvector

interactive problem

two sum solution

interpolation search

Required Length

new expression

Targon lol

xor linked list

stack implementation

typescript

loop through array

loop array

how to point to next array using pointer c++

file exist

floating point exception

array di struct

castin in C++

varint index

how to make a instagram report bot python

windows servis from console app

add integers

listas enlazadas/ linked lists

niet werkend

bubble sort

triangle angle sum

divisor summation

rotateArray

destiny child

Populating Next Right Pointers in Each Node

cosnt cast

bucket sort

double plus overload

Z-function

binary search

permutation

linked list

Implicit conversion casting

square root

public method

tower of hanoi

selection sort

dangling pointer

hello world programming

statements

volumeof a sphere