This question already has answers here:
EXC_BAD_ACCESS signal received
(36 answers)
Closed 9 years ago.
I am trying to finish an assignment for my C programming class on Xcode. It's simple. It reads a text file, which contains a list of student IDs and their test scores. And then it calculates the overall score based on these data, and writes them to another text file. However, I keep getting this Bad Access error message that says:
Thread 1: EXC_BAD_ACCESS(code=1, address=0x7fff00000de4)
I don't know what it means. What should I do?
The EXC_BAD_ACCESS means that you tried to attempt the incorrect address in memory.
You should start with the following:
Check that all pointers are initialized before using
If you have an array, so possibly you are trying to access the element that is out of bounds
And of course, use the debugger.
Related
This question already has answers here:
Non blocking getch()
(2 answers)
Closed 3 years ago.
I am making a typing game in C Language in this game letters come from the top of the window and user has to type that letter to delete it and to stop it from touching the specific boundary line if it touches the boundary line user lose points and ultimately lose the game. Now I am having trouble to print the list of the characters and take input at the same time. If I tried to use the scanf() or getch() function they both stop the printing process is there any way that I could get input from a user without stopping the printing process.
Kbhit Function really Works for that problem.
This question already has answers here:
What is the purpose of the returning of a value from main() in C/C++? [duplicate]
(5 answers)
Closed 7 years ago.
Why do we have to use 'return 0' statement in C?
in the end of main function. I know This means all things are going on way. But what does it mean? What exactly are there at the background of this ?
It returns a number to the environment that started it... Every process begins with a set of arguments and returns an int indicating success or failure
see So what does "return 0" actually mean?
Potentially, a calling process can read the result and use it as information on what the execution of the program did.
This question already has an answer here:
Determining if file has been copied or not in C [closed]
(1 answer)
Closed 9 years ago.
In Windows, if you go to a file's properties it shows the last access time right under the time last modified. This changes when I copy it.
How do I view this in C?
You can use the GetFileTime() function to get it. This MSDN article has more details about file times.
The portable way of getting the last modified timestamp is by using fstat or stat. If you want to go the Windows-only route (by directly calling a Windows API), see #xxbbcc's answer.
See How can I get a file's size in C++? for a short piece of sample code that uses stat/fstat - only change for your purpose is that you'll want to read the time_t st_mtime field.
This question already has answers here:
C code won't finish running
(4 answers)
Closed 9 years ago.
The purpose of this code is to construct a char Hadamard matrix of the size of my choosing.
This question is related to a previous question I asked. The answer given there was an integer not char matrix, but the code here is pretty much the same format.
The code compiles but when executed it doesn't finish and I don't know why. When executed infinite 2's are printed.
I get the same result when swap the dynamic Hadamard matrix section for one of a fixed size.
Note: I've no idea what your program does, but obviously this is wrong. You failed to actually change the control variable in your for-loop (which can be done in the final expression or the loop body itself).
Change this:
for (ind=1;ind<=sizeH;ind*2)
to this:
for (ind=1;ind<=sizeH;ind*=2) // << note *=
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Debugging a program that crashes 10 times in different places
You are given a the source to a application which is crashing when
run. After running it 10 times in a debugger, you find it never
crashes in the same place. The application is single threaded, and
uses only the C standard library. What programming errors could be
causing this crash? How would you test each one?
Pointer error. You're trying to read/write an undefined pointer - do a find and replace for free(x) -> free(x);x=NULL.
Edit: Should also check for assignment; are you doing anything like this?
int *a;
a++;