sizeof operator not functioning
#1

So I'm not sure why but the sizeof operator is throwing an error when the parameter is a string residing in an enumarator.

Код:
format(tpInfo[tpID][tpName], sizeof(tpInfo[tpID][tpName]), "");
Any help would be appreciated.
Reply
#2

set the size manually in this case.
Код:
format(tpInfo[tpID][tpName], 50, "");
Reply
#3

Do you think anyone can help you with the information you gave us? You said it throws an error, it would be logical to at least post the error here.

My wild guess is that you didn't specifically make the variable a string. Can't help much more than that without more details.
Reply
#4

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
set the size manually in this case.
Код:
format(tpInfo[tpID][tpName], 50, "");
That is exactly what I do not wish to do. If this is the penultimate solution to this problem then I guess I will have no other option than using a MACRO for this.

Quote:
Originally Posted by Phreak
Посмотреть сообщение
Do you think anyone can help you with the information you gave us? You said it throws an error, it would be logical to at least post the error here.

My wild guess is that you didn't specifically make the variable a string. Can't help much more than that without more details.
[spoiler][/spoiler]
Reply
#5

why not use format(tpInfo[tpID][tpName], TP_NAME_SIZE, "");
Reply
#6

Quote:
Originally Posted by m4karow
Посмотреть сообщение
why not use format(tpInfo[tpID][tpName], TP_NAME_SIZE, "");
That's the solution that I used after I couldn't get sizeof to work. Which is odd TBH. I want to know what is the problem with the operator.
Reply
#7

The error says everything. It expects a closing bracket but it got an identifier.

sizeof wants to get the size of the variable itself (in this case the length of the array) so it expects tpInfo[][];
Reply
#8

Enums are eventually heterogeneous form of an array. At least that's what I thought so far. A slot within the enum returns 1, such confusion. I assumed the slot is reserved for the mentioned string. But the value that it's returning kinda threw me off guard.

My question is never the less answered. Thank you.

This may be closed.
Reply
#9

May be syntax is wrong.....but wait I will respond quickly for it
Reply
#10

Using sizeof(tpInfo[][tpName]) was of no help. Same errors occured
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)