User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2004
Posts: 18
Reputation: hill0ster is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
hill0ster hill0ster is offline Offline
Newbie Poster

need info? can't use strcmp/string compare

  #1  
Oct 25th, 2004
#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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 7
Reputation: jwstickley is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
jwstickley jwstickley is offline Offline
Newbie Poster

Re: need info? can't use strcmp/string compare

  #2  
Oct 26th, 2004
use memcmp
Reply With Quote  
Join Date: Sep 2004
Posts: 6,333
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 28
Solved Threads: 458
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: need info? can't use strcmp/string compare

  #3  
Oct 26th, 2004
>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.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 4:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC