memory write access violation error...???

Discuss Programming / Linux questions.

Moderators: scallenger, Sky, TresCom Support Team

Post Reply
Lou-saydus
Pteranodon
Pteranodon
Posts: 983
Joined: Wed Sep 10, 2003 11:18 pm

memory write access violation error...???

Post by Lou-saydus »

uh will thats about it.....
here is the code

Code: Select all

/* Logs 0.1
Tuesday, September, 1:57 pm, 2004

Logs logins.
thats about it...
*/
#include <stdio.h>
#include <time.h>

FILE CreateLog(char filename[]);
void Log(char string[]);
char GetDateTime(char string[]);
int  Password(void);


main()
{
	Password();
}

/* Function CreateLog definition */
FILE CreateLog(char filename[])
{
	FILE *fptr;
   fptr = fopen(filename, "a+");

   return *fptr;
}
/* Function Log definition */
void Log(char string[], FILE *fptr)
{
	fputs(string, fptr);
}
/* Function GetDateTime definition */
char GetDateTime(void)
{
	time_t timeT;
   char string[90];

   time(&timeT);
   asctime(localtime(&timeT));
   *string = timeT;
   return *string;
}
/* Function Password definition */
int Password(void)
{
	char pass[8], string[90], filename[] = "Login.log", LogS[90], TESTLOG[] = "TEST";
   FILE *fptr;
   int reval, c;

   *fptr = CreateLog(filename);
   *LogS = GetDateTime();
	printf("Enter password.\n", pass);
   scanf("%s", &pass);
   printf("pass = %s", pass);

   if (pass == "123"){
   	printf("Access granted.\nLogin clear.\n");
      printf("Ready? (Y/N)\n");
      	while(c != 'Y'){
      	c = getc(stdin);
      	}
      reval = 1;
   } else {
   	Log(TESTLOG, fptr);
		printf("Access denied.\nLogin attempt has been loged.\n");
   	printf("Ready? (Y/N)\n");
      	while(c != 'Y'){
      	c = getc(stdin);
      	}
      reval = 0;
      }

   return reval;
}
in the "Password" function declaration the while statement gives
me a error. but if i change it to a for statement it dosnt.

any one know whats up?
jamesblonde001
Parasaurus
Parasaurus
Posts: 45
Joined: Sun Mar 28, 2004 7:33 am

Post by jamesblonde001 »

same error occur when password is correct?
can you step through the code at runtime? If so what happens just after the while?

I dunno much bout C or C++ and my programming is 5 years rusty...
Hope this helps a bit.
"I dream for a living." - Steven Spielberg
Lou-saydus
Pteranodon
Pteranodon
Posts: 983
Joined: Wed Sep 10, 2003 11:18 pm

Post by Lou-saydus »

at build time i get this error.
Remdul
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 1845
Joined: Mon Jul 22, 2002 12:35 pm
Location: Holland, Europe

Post by Remdul »

What kind of error?
Lou-saydus
Pteranodon
Pteranodon
Posts: 983
Joined: Wed Sep 10, 2003 11:18 pm

Post by Lou-saydus »

Thread stopped
C:\BC5\BIN\Logs.exe: Fault:
access violation at 0x401136:
write of address 0x0


ok only
Post Reply