need Help w/ c++ program, please I am a new.

November 6, 2010 at 20:37:08
Specs: Macintosh
this is my program it supposes to compare word or string with an array of pointers and return 0 or 1
Plz help me i cann't sleep if i have something wrong
//////////////////////////////////


#include <iostream.h>

const int days_week =8;

int main (int argc, char * const argv[]) {

int check_password(char*);
char password[21];
cout << "Enter your password : ";
cin >> password;
cout << "\ncheck_password Function called\n";

int ans =check_password(password);
if (ans=0)
cout << "True PassWord!!!" << endl;
if (ans!=0)
cout << "Falls PassWord!!" << endl;
return 0;
}

/////////////// Here Is the Problem with This Function////////////////

int check_password(char* paswrd)
{
char* prt_arr[days_week] = {
"Sunday","Monday","Tuesday",
"Wedensady", "Thursday",
"Frieday", "Saturday" };

for (int j; j<7; j++) {

if ( *prt_arr[j] == *paswrd)
return 0;
else
return 1; }
}


See More: need Help w/ c++ program, please I am a new.

Report •


#1
November 11, 2010 at 23:18:56
#include <iostream.h>
#include <string.h>

const int days_week =8;

int main (int argc, char * const argv[])
{
int check_password(char*);
char password[21];
cout << "Enter your password : ";
cin >> password;
cout << "\ncheck_password Function called\n";
cout << endl;

int ans =check_password(password);

if (ans==0)
cout << "True PassWord!!!" << endl;

if (ans!=0)
cout << "Falls PassWord!!" << endl;
return 0;
}

/////////////// Here Is the Problem with This Function////////////////

int check_password(char* paswrd)
{
char* prt_arr[days_week] = {
"Sunday","Monday","Tuesday",
"Wedensady", "Thursday",
"Frieday", "Saturday" };

for (int j=0; j<7; j++)
{
if ( strcmpi(prt_arr[j], paswrd) )
return 0;
}
return 1;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Sleep now......

...................................................................................................................

_Adnan_


Report •

#2
November 12, 2010 at 23:41:38
thank you again and again its work i add only (!) to : if ( strcmpi(prt_arr[j], paswrd) )
and its work SO
i am going to sleep now good night
hhh

Report •

#3
November 13, 2010 at 04:30:01
you're welcome.

Report •
Related Solutions


Ask Question