C++ String Comparison (using String.Compare, String Methods, Loops)

C++ String Comparison

Write a program that asks the user to enter two names and store them in string objects.. It should then report whether they are the same or not, ignoring case, To help accomplish its task, it should use two functions in addition to main(). The functions are: StringUppercaseIt(string s) boolean sameString(string s1, string s2)

The sameString function, which receives the two strings to be compared, will need to call uppercaseIt for each of them before testing if they are the same. The uppercaseIt function should use a loop so that it can call the toupper function for every character in the string it receives before returning it back to the sameString function.

Learning to code? Follow my C++ tutorials for beginners. I do a lot of C++ programming challenges and C++ projects as part of my homework – every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don’t forget to subscribe, as I release new programming videos every day!

Nguồn: https://ka-nom.com/

Xem thêm bài viết khác: https://ka-nom.com/cong-nghe/

Related Posts

Data Recovery for Mac | MacBook/MacBook Pro (SSD) | Stellar Phoenix Data Recovery Pro Free

July 10, 2020

July 10, 2020 13

The best data recovery software for Mac OS X. Recover deleted or lost data from any storage device. 100% virus...

State of Decay 2 Free Download (PC)

July 8, 2020

July 8, 2020 19

Download Link: How’s it going guys! In this video, I’ll be showing you how to download State of Decay 2...

Hướng dẫn tải và cài đặt STATA 11, 13, 14 cụ thể cho Windows và MAC

July 7, 2020

July 7, 2020 27

Hướng dẫn tải và cài đặt STATA 11, 13, 14 cụ thể cho Windows và MAC đầy đủ bản quyền...

How to get Stick Fight The Game for FREE on PC! 2019 (Cracked)

July 9, 2020

July 9, 2020

Today I am showing you guys how to get Stick Fight the Game for free as a cracked version on...

Stick War Legacy | Mua 1 lần được 999999999 Item | Stick War Legacy Hack | KasubukTQ

July 13, 2020

July 13, 2020 27

Stick War Legacy | Mua 1 lần được 999999999 Item | Stick War Legacy Hack | KasubukTQ ⬇️Cách tải game...

Curso de React Native #26: Status Bar

July 9, 2020

July 9, 2020 4

Curso de React Native: Neste vídeo você vai aprender como controlar a aparência da barra de status (Status Bar) no...

React Native Custom App Statusbar

July 7, 2020

July 7, 2020 2

React Native Fun Learn how to create custom Statusbar in your react native application or iPhoneX and newer iOS devices...

[Lập trình C/C++] Bài 33. Xây dựng hàm so sánh 2 chuỗi có phân biệt hoa thường – strcmp

July 8, 2020

July 8, 2020 5

– Source code: – Nguyên tắc so sánh 2 chuỗi: Ví dụ: so sánh 2 chuỗi s1, s2 – Lấy...

Misthy Lần đầu sang nhà Viruss. Và tiết lộ khủng từ Viruss || LIKE A PRO

July 11, 2020

July 11, 2020 21

Hihi nhà anh Viruss có nhiều thứ thú dị để xin xỏ quá đi nà. Mấy ông nhớ ủng hộ...

strike force heroes 2 hacked 2016 – (updated and working) God mode, unlimited weapons and golden gun

July 12, 2020

July 12, 2020 17

Get your strikes force heroes 2 hacked here : Other Keywords( ignore these ) strike force heroes 2 hacked air...

Stellar Phoenix Outlook PST Repair Review

July 7, 2020

July 7, 2020 1

* Facebook: * Twitter: * Google Plus: * Pinterest: * LinkedIn: ******* Andreas Christodoulou is the creator and editor of...

String Comparison Function – strcmp()

July 11, 2020

July 11, 2020 13

C Programming: String Comparison Function – strcmp() in C Language. Topics discussed: 1) The prototype of strcmp() function. 2) Functionalities...

[Crack] Add ANY Steam game to your library ! [3.0]

July 9, 2020

July 9, 2020 20


Static for Classes and Structs in C++

July 9, 2020

July 9, 2020 27

Twitter ► Instagram ► Patreon ► Slack ► Series Playlist ► Static in a global scope ► Check out my...

ONE SWORD VS FINAL BOSS 💛 | Stick war legacy

July 13, 2020

July 13, 2020 17

Subscribe and hit the bell icon to be updated on the series!! {DOWNLOAD THE GAME NOW AND SUPPORT THE GAME...

  • could you do a switch case once the comparison was done? i want to do a switch case for like for if north or n go to a north place, then if south or s then go to south place?

  • Two names ????? please i have a problem with collection of strings compare and sort them… Like sorting by video category

  • Man, the best i could find in this vast world of internet, there are no spanish youtubers who explains this case, they use c style string to explain it (pretty tired of it,, i am a c++ student) you got my like buddy!

  • #include <iostream>
    #include <stdlib.h>
    #include <stdio.h>
    #include <math.h>
    #include <iomanip>
    #include <string>
    #include <vector>
    #include <ctype.h>
    #include <algorithm>

    using namespace std;

    string upperCase(string z){
    for(int i=0; i<z.length(); i++){
    z[i] = toupper(z[i]);
    return z;

    void sameString(string a, string b){
    if(upperCase(a) == upperCase(b)){
    cout << "Same" << endl;
    cout << "Different" << endl;

    int main() {
    string in, in2;
    cout << "- Same Name Testing Machine -" << endl << endl;
    cout << "Enter the first name here ";
    getline(cin, in);
    cout << "Enter the second name here ";
    getline(cin, in2);
    sameString(in, in2);

    return 0;

  • How can you compare 2 strings, one element at a time? For instance, if you have 2 strings "0011" and "0010" and you want to perform an OR bitwise operation on it?

  • How about removing the first occurrence of the second c-String argument from the first c-string. And returns the index position in the first c string where the second Beas found otherwise return -1 ?

Leave a Reply

Your email address will not be published. Required fields are marked *