1) the declaration s (data types) of your variables should match those in the function header. You mix data types:
declaration of variables:
int x, y, v, c, ck, STemp, STable;
char Temp[30], Table[3][3];
use in function header:
void CLEAR(uchar8 *Temp, uint8 STemp, uchar8 *Table, uint8 STable, uint8 *x, uint8 *y, uint8 *v, uint8 *c, uint8 *ck)
You should stick to one data type, e.g. either int or uint, but do not mix them. This would lead to:
void CLEAR(char *Temp, int STemp, char *Table, int STable, int *x, int *y, int *v, int *c, int *ck)
Which still isn't correct.
2) Let''s analyze this fragment:
void CLEAR(char *Temp, int STemp, char *Table, int STable, int *x, int *y, int *v, int *c, int *ck)
Since Temp is declared as
char Temp[30]
Temp (without * or &) is a pointer to the array. Therefore you can use Temp (without any qualifier) to submit the address of the array to the subroutine.
The same is true for Table.
x, y etc. are defined as:
int x, y, v, c, ck;
Therefore, in order to get the address of one of these variable you need to qualify the variable by the & sign:
address of x = &x
In the function header the syntax ... int *x... signifies that you will not handle the value of x, but its address. So this part of your code looks o.k.
In all, the code should like something like this:
main()
{...
CLEAR(Temp, STemp, Table, STable &x, &y, &v, &c, &ck);
...}
void CLEAR(char *Temp, int STemp, char *Table, int STable, int *x, int *y, int *v, int *c, int *ck)
{...}
I have two tips:
1) It may be easier to first get a grasp of the C syntax by using a C complier on the pC and get a feeling for the language. E.g. the free personal edition of Microsoft Visual Studio or GCC.
2) Using pointer (addresses) in C is rather easy, once you have understood the concept. However, even professionals time and again stumble over runtime errors caused by pointers that contain wrong or even illegal values. This can happen, for example, if you assign a value to a pointer without completely checking the validity of the value or if you do pointer arithmetic (increment, decrement are good candidates).
I therefore recommend that you deeply consider whether it is wise to use a pointer or if another, less critical method can do the job.
In your example, you could have
either:
- placed the short piece of code for nulling the arrays and variables into the main code. Unless you need this subroutine more than once, this will save you runtime overhead since no subroutine call needs to be performed.
or:
- made the arrays and the variables global variables. You can then access them by the subroutine without the need to handle pointers.
Every method has advantages and drawbacks. Which one prevails depends on the particular programming problem at hand.
Oh, and one very general tip: When you are dealing with a new situation in programing (e.g. syntax elements, data structures etc that are new to you) I suggest starting with very basic examples to get a grasp of the problem and its solution in the programming language used. In the above example, it would have been a good idea to start with justa single variable to learn the concepts of the * and & operator.
Here
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/ is a tutorial on C programming (including pointers).
Harald