ok new problems...
Here is what I have when I run the program:
Code:
[Session started at 2005-11-12 19:45:55 -0500.]
Please enter your name
darth
Please enter your password
23456
please enter a correct name
Darth
please enter a correct password
23456
Final Project has exited due to signal 10 (SIGBUS).
[Session started at 2005-11-12 19:49:13 -0500.]
Please enter your name
darth
Please enter your password
23456
please enter a correct name
leia
please enter a correct password
12345
Final Project has exited due to signal 10 (SIGBUS).
Here is what my code looks like:
Code:
/*William Edward McFadden */
/* Location of all files is at: */
/* /users/williammcfadden/Documents/school/EGR 115/Final Project/ */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* function Declarations */
int password(FILE *);
main()
{
FILE *Fpassword;
FILE *Fplanes;
FILE *Fdistout;
Fpassword=fopen("/users/williammcfadden/Documents/school/EGR 115/Final Project/password.txt", "r");
Fplanes=fopen("/users/williammcfadden/Documents/school/EGR 115/Final Project/planes.txt", "w");
Fdistout=fopen("/users/williammcfadden/Documents/school/EGR 115/Final Project/distlog.out", "w");
/************************************************** **********************************************/
/************************************************** **********************************************/
/*password function */
password(Fpassword);
if (Fpassword == 1);
{
printf("Sorry you really should not be using this program \n");
system ("pause");
exit(0);
}
printf("hello ya'll \n");
fclose(Fpassword);
fclose(Fplanes);
fclose(Fdistout);
}
/************************************************** **********************************************/
/************************************************** **********************************************/
/************************************************** **********************************************/
/************************************************** **********************************************/
/************************************************** **********************************************/
int password(FILE *Fpassword)
{
char NAME[50];
int PASSWORD;
int l;
char* name[6];
for(l=0; l<6; l++)
{
name[l]= malloc (50);
}
int password[6];
int i;
int h;
int R;
int z;
for(i=0; i<6; i++)
{
fscanf(Fpassword, "%s",name[i]);
fscanf(Fpassword, "%d",&(password[i]));
}
printf("Please enter your name \n");
scanf("%s", NAME);
printf("Please enter your password \n");
scanf("%i", &PASSWORD);
for(h=0; h<6; h++)
{
if(0==strcmp(NAME, name[h]) && PASSWORD == password[h])
{
return 1;
}
else {
printf("please enter a correct name \n");
scanf("%s",NAME);
printf("please enter a correct password \n");
scanf("%i",PASSWORD);
for(R=0; R<6; R++)
{
if (0==strcmp(NAME, name[R]))
{
if (PASSWORD== password[R])
{
return 1;
}
}
}
{
printf("ONE LAST TIME BUDDY \n");
printf("please enter your name \n");
scanf("%s", NAME);
printf("please enter your password");
scanf("%i", PASSWORD);
for(z=0; z<6; z++)
{
if( 0==strcmp(NAME, name[z]))
{
if (PASSWORD == password[z])
{
return 0;
}
}
}
}
}
}
}
/************************************************** **********************************************/
/************************************************** **********************************************/