•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 427,380 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,007 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 3786 | Replies: 2
![]() |
•
•
Join Date: Oct 2004
Posts: 18
Reputation:
Rep Power: 5
Solved Threads: 0
#include <iostream>
#include <cstring>
using namespace std;
bool equalStrings (char[], char[]); //given here but must complete
// on midterm
int main()
{
char str1[80];
char str2[80];
cout << "Enter your first string: " << endl;
cin.getline(str1);
cout << "Enter your second string: " << endl;
cin.getline(str2);
if (equalStrings (str1, str2) ) //on mt fill in call
cout << "The two strings are identical." << endl;
else
cout << "The two strings are NOT identical." << endl;
}
//Write the function header and body of equalStings
/*
Sample Runs;
Enter your first string; hello--- //-means blank
Enter you second string; hello
The two strings are NOT identical
Sample Runs;
Enter your first string; jon
Enter you second string; joN
The two strings are NOT identical
Sample Runs;
Enter your first string; jane doe
Enter you second string; jane doe
The two strings are identical
#include <cstring>
using namespace std;
bool equalStrings (char[], char[]); //given here but must complete
// on midterm
int main()
{
char str1[80];
char str2[80];
cout << "Enter your first string: " << endl;
cin.getline(str1);
cout << "Enter your second string: " << endl;
cin.getline(str2);
if (equalStrings (str1, str2) ) //on mt fill in call
cout << "The two strings are identical." << endl;
else
cout << "The two strings are NOT identical." << endl;
}
//Write the function header and body of equalStings
/*
Sample Runs;
Enter your first string; hello--- //-means blank
Enter you second string; hello
The two strings are NOT identical
Sample Runs;
Enter your first string; jon
Enter you second string; joN
The two strings are NOT identical
Sample Runs;
Enter your first string; jane doe
Enter you second string; jane doe
The two strings are identical
>use memcmp
Brilliant! No, not really. If not being able to use strcmp is a requirement of the function then clearly it's homework and using memcmp would result in a failing grade.
However, I won't make a suggestion other than looping over the contents of both arrays and making comparisons because the OP didn't show an honest attempt at writing the function. It isn't terribly difficult if you expend a little energy trying.
Brilliant! No, not really. If not being able to use strcmp is a requirement of the function then clearly it's homework and using memcmp would result in a failing grade.
However, I won't make a suggestion other than looping over the contents of both arrays and making comparisons because the OP didn't show an honest attempt at writing the function. It isn't terribly difficult if you expend a little energy trying.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- hi.. string compare (Java)
- How to compare two strings? (C)
- string: get token from string and compare token from text file (C++)
- How to see if one string is less than another string (C)
- string compare and fstream (C)
Other Threads in the C++ Forum
- Previous Thread: same sort of programs?
- Next Thread: Dial tone detecting before performing a call!!



Linear Mode