RSS Forums RSS

Unhandled exception and Access violation for every program

Please support our C advertiser: Programming Forums
Reply
Posts: 39
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Unhandled exception and Access violation for every program

  #1  
Jan 4th, 2009
I was working on some programs and now, no matter which one I run, I get an error like this: Unhandled exception at 0x00411be0 in program.exe: 0xC0000005: Access violation writing location 0x00130000.

Any ideas what is causing this or how I can fix it?
AddThis Social Bookmark Button
Reply With Quote  
Posts: 717
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 80
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Master Poster

Re: Unhandled exception and Access violation for every program

  #2  
Jan 5th, 2009
Have you ran through the code till this occurred?
And actual code is nice, too.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote  
Posts: 39
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Re: Unhandled exception and Access violation for every program

  #3  
Jan 5th, 2009
There are specifically two of them that are giving me this problem. The error appears as a pop-up. The debug tool, however, doesn't show an error.

#include <stdio.h>
#include <string.h>
#include "string.h"
void assemble(char*input, int num, char let, float flo);

int main() 
{
	char input[255];
	int num;
	char let;
	float flo;

printf("\nPlease enter an integer:\n");
	scanf("%d", &num);
	printf("\nPlease enter a character:\n");
	scanf("%c", &let);
	printf("\nPlease enter a floating point number:\n");
	scanf("%f", &flo);

	assemble(input, num, let, flo);
	puts(input);
	return 0;
}

void assemble(char *input, int num, char let, float flo)
 {	
	sprintf(input, "%d, %c, %f", num, let, flo);	
 }

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>


int main()
{
	#define MAXCHARS 300
	void convertToUpper(char[]);
	FILE *inFile;
	char fileName[25];
	char text[MAXCHARS];

	printf("\nEnter a file name: ");
	gets(fileName);
	inFile = fopen(fileName, "r"); /*This opens the file */
	if (inFile == NULL)			   /*Checks that the file exists*/

	{
		printf("\nThe file %s was not opened successfully.", fileName);
		printf("\nPlease check that you entered the file name correctly.\n");
		exit(1);
	}
	while (fscanf(inFile, "%s", text) !=EOF) /*Reads and displays the file*/

		convertToUpper(text);
		printf("%s\n", text);
	fclose(inFile);
	return 0;
}

void convertToUpper(char text[MAXCHARS])
{
	int i;
	for(i = 0; text[i] != '0'; i++)
		text[i] = toupper(text[i]);
}
Last edited by RenFromPenn : Jan 5th, 2009 at 12:05 pm.
Reply With Quote  
Posts: 39
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Re: Unhandled exception and Access violation for every program

  #4  
Jan 5th, 2009
I managed to fix the first one, so now I just need help with the second program.
Reply With Quote  
Posts: 717
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 80
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Master Poster

Re: Unhandled exception and Access violation for every program

  #5  
Jan 5th, 2009
You do not declare, or define functions in other functions.
Macros tend to go outside publicly.
Are you actually modifying text[] in convertToUpper()?
You loop and call a function, but only call printf() once, because you're missing something.
If the file didn't open, do you have to frantically escape, and not just pass over code with an if-else condition?
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote  
Reply

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



Views: 814 | Replies: 4 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:02 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC