assign the value of an array to a pointer c++
Hello @ all
I`m trying to do the following:
content of array is at this index 0x00
pTest->tst = user_tst;
which doesn't work and stucks me to the following error:
error C2109: subscript requires array or pointer type.
the array comes from another file and is well defined(there) as it is also made external in the included header file.
I would be glad, if anyone could give me a hint or point me to correct direction.
Thanks for every read/help.
here you are (code snippets)
thx for your reply
here is the relevant code:
file1 filling the array:
char variable = "";
char * pch;
int i = 0;
printf("Enter desired Data in this style XX-XX-XX-XX-XX-XX : \n");
scanf("%s", &variable); //user input to address of variable
pch = strtok (variable, "- :");
while (pch != NULL)
printf("%s \n",pch); //control of splitting
sscanf (pch, "%x", &tst_user[i]); //filling
pch = strtok (NULL, "- :");
printf("array index %d = %#x \n",i, tst_user[i++]); //control array and add 1 to index
extern int tst_user;
file 2 assigning the array to the pointer:
manually(static) assigning works just fine:
pTest->tst = tst_user);
but this is not what i want.
pTest->tst = 0x00;
The code is very long and the failure should be in the assignment or the interchange of the array itself.
i also tried it with:
which gives the same error.
pTest->tst = static_cast<int>(tst_user);
Thanks for reading/helping
problem is in sharing the array itself
Hi @ all
Sorry, I have to correct myself,
I think youre right, the correct making external should be with the index().
the array definition got lost cause i redefined it as an standard integer (without the index).
So i think the compiler thinks it is an standard variable and therefore the type failure error.
But in correct defining
there is the problem with the unresolved external, which i should focus on.
extern int tst_user;
error LNK2001: unresolved external symbol "int * tst_user" (?tst_user@@3PAHA)
This says nothing to me and English isn't my mother tongue and googeling the prob also doesn't help.
Could anyone please explain me the error above or give me a hint
what im doing wrong?
Thx for reading/helping