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
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.
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein
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?
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Post your code. Even though VC6 isn't great in terms of ANSI compatibility, it's not too bad.
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein
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])
Last edited by Dave_Sinkula; 04-05-2005 at 04:35 PM.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.