I always get error report running C program in VC. It seems that some symbol interpretation not installed? How to deal with it?
Thanks
robin
Printable View
I always get error report running C program in VC. It seems that some symbol interpretation not installed? How to deal with it?
Thanks
robin
You have two choices:
1) Post your errors so that we can help you.
2) Google your errors.
When I step into code:
have such error for any fuction:
Unhandled exception in ...exe. :0xC0000005:access violation
I guess I should install some "patch" for VC6.0 that make it can run any ansi C code.
I tried my VC6.0 and in common lab. Both can not run c code.
anybody give an solution?
Fix the bug(s) in your code?
Post your code. Even though VC6 isn't great in terms of ANSI compatibility, it's not too bad.
Your "access violation" most likely has nothing to do with the compiler, and more to do with buggy code you've written.
I suggest posting your code here.
sorry.
How to post code? Format?
The main function is like following
=================================
Code:# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <conio.h>
# define TRUE 1
# define FALSE 0
# define SIZE 101
long int record_arr();
void insertion_sort();
void merge_sort(long m,long n);
void merge(long m,long k,long n);
void quick_sort(long m,long n);
long int partition(long m,long n);
long int array[SIZE];
long int c[SIZE];
long i,j,m,n;
long val,max;
long k;
char str[3]={'i','m','q'};
FILE *in,*out;
main()
{
char test='i';
if((in=fopen("in.txt","rt"))==NULL)
{printf("cannot open input file\n");
exit(0);
}
if((out=fopen("out.txt","wt"))==NULL)
{printf("cannot open output file\n");
exit(0);
}
if(strcmp(test,str[0])==0)
{ max=record_arr();
insertion_sort();
for(i=0;i<max;i++)
fprintf(out,"%d \n",array[i]);
}
else if(strcmp(test,str[1])==0)
{ m=0;
n=record_arr();
merge_sort(m,n-1);
for(i=0;i<n;i++)
fprintf(out,"%d \n",array[i]);
}
else if(strcmp(test,str[2])==0)
{ m=0;
n=record_arr();
quick_sort(m,n-1);
for(i=0;i<n;i++)
fprintf(out,"%d \n",array[i]);
}
else
{
printf("Sorting type parameter error!, try to use i/m/q for type of sorting \n");
exit(0);
}
printf("program finished now!");
fclose(in);
fclose(out);
// getch();
}
Both arguments to strcpy are supposed to be strings -- test, str[0], str[1], and str[2] are single characters (not strings). If you just want to do a single-character compare, do this:Code:if(test == str[0])
Thanks
Dave_Sinkula
I think that's the problem.
But why it is valid in turbo c?
> But why it is valid in turbo c?
It isn't.
The compiler is probably too dumb to generate an error message.
DOS has NO memory protection at all, so you're free to overwrite anything you like. Of course, later on, random other things go wrong and your program then dies.