View Single Post
Join Date: Dec 2008
Posts: 40
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

 
0
  #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.

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "string.h"
  4. void assemble(char*input, int num, char let, float flo);
  5.  
  6. int main()
  7. {
  8. char input[255];
  9. int num;
  10. char let;
  11. float flo;
  12.  
  13. printf("\nPlease enter an integer:\n");
  14. scanf("%d", &num);
  15. printf("\nPlease enter a character:\n");
  16. scanf("%c", &let);
  17. printf("\nPlease enter a floating point number:\n");
  18. scanf("%f", &flo);
  19.  
  20. assemble(input, num, let, flo);
  21. puts(input);
  22. return 0;
  23. }
  24.  
  25. void assemble(char *input, int num, char let, float flo)
  26. {
  27. sprintf(input, "%d, %c, %f", num, let, flo);
  28. }

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5.  
  6. int main()
  7. {
  8. #define MAXCHARS 300
  9. void convertToUpper(char[]);
  10. FILE *inFile;
  11. char fileName[25];
  12. char text[MAXCHARS];
  13.  
  14. printf("\nEnter a file name: ");
  15. gets(fileName);
  16. inFile = fopen(fileName, "r"); /*This opens the file */
  17. if (inFile == NULL) /*Checks that the file exists*/
  18.  
  19. {
  20. printf("\nThe file %s was not opened successfully.", fileName);
  21. printf("\nPlease check that you entered the file name correctly.\n");
  22. exit(1);
  23. }
  24. while (fscanf(inFile, "%s", text) !=EOF) /*Reads and displays the file*/
  25.  
  26. convertToUpper(text);
  27. printf("%s\n", text);
  28. fclose(inFile);
  29. return 0;
  30. }
  31.  
  32. void convertToUpper(char text[MAXCHARS])
  33. {
  34. int i;
  35. for(i = 0; text[i] != '0'; i++)
  36. text[i] = toupper(text[i]);
  37. }
Last edited by RenFromPenn; Jan 5th, 2009 at 1:05 pm.
Reply With Quote