| | |
Unhandled exception and Access violation for every program
![]() |
•
•
Join Date: Dec 2008
Posts: 40
Reputation:
Solved Threads: 0
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.
C Syntax (Toggle Plain Text)
#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); }
C Syntax (Toggle Plain Text)
#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 1:05 pm.
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?
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
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
![]() |
Similar Threads
- Debug Assertion Failed! Error - how do I fix this? (C++)
- Unhandled exception at 0x5f4335bb (MFC42D.DLL) in .exe,Access violation (C++)
- Unhandled Exception Error (C++)
- DirectX and C++ DrawIndexedPrimitive question (C++)
- file read and buffer problems (C++)
- explorer.exe crashes when right-click .mp3s- HJT log (Viruses, Spyware and other Nasties)
- Exercise using: unsigned char bcd(int n); (C)
- Visual C++ program compiles, but won't run (C++)
- How to be Crash Free (C++)
Other Threads in the C Forum
- Previous Thread: Calling C++ function from C code
- Next Thread: Need examples of menu choices contected to linked lists
| Thread Tools | Search this Thread |
#include * ansi api array arrays binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send sequential shape single socket socketprogramming stack standard strchr string suggestions test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi





