MIPS to C Translation
You’ve got this back-to-front. It is a store, so it is used:
You’ve got this back-to-front. It is a store, so it is used:
Two errors here: first, you’re trying to declare arrays[63] for storing 64 elements, as you’ve probably confused the size of array (n) with the maximum possible index value (that’s n – 1). So it definitely should be litera[64] and liczba[64]. BTW, you have to change this line too – while (i<=64): otherwise you end up trying to access 65th element. And second, you’re trying … Read more
You can’t return two values. However, you can return a single value that is a struct that contains two values.
Replace float cents = with cents = in your while loops. Currently you’re trying to declare a new variable cents which shadows the existing one. Technically this is valid C, perhaps your compiler (thankfully) has this warning set to an error? Note that you could optimise much of your logic to O(1) using integer division and careful checking with your debugger. Repeatedly subtracting from a value is … Read more
In C I typically create a function in the style of a constructor which does this. For example (error checking omitted for brevity)
This error occurs because some other part of your code has corrupted the heap. We can’t tell you what that error is without seeing the rest of the code. The fact that FINE 7 is not printed tells you that realloc is failing. And that failure must be because buffer is invalid due to a heap corruption earlier in the execution. … Read more
From what the error message complains about, it sounds like you should rather try to fix the source code. The compiler complains about difference in declaration, similar to for instance and this is not valid C code, hence the compiler complains. Maybe your problem is that there is no prototype available when the function is … Read more
you end up with cant_corte[i] is 0, and then you strv[i][cant_corte[i] -1] = ‘\0’; so strv[i][-1] is not a valid address to write. i do encourage you to learn how to use valgrind with gdb as explained at http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver-simple
The problem is that you’re attempting to modify a string literal. Doing so causes your program’s behavior to be undefined. Saying that you’re not allowed to modify a string literal is an oversimplification. Saying that string literals are const is incorrect; they’re not. WARNING : Digression follows. The string literal “this is a test” is of an expression of type char[15] (14 … Read more
Syntax of waitpid(): The value of pid can be: < -1: Wait for any child process whose process group ID is equal to the absolute value of pid. -1: Wait for any child process. 0: Wait for any child process whose process group ID is equal to that of the calling process. > 0: Wait for the child whose … Read more