I have a number of xmlChar * in my source file and I need them to be in integer form.
How does one cast these correctly?
When I tried this world->representation = malloc(sizeof(int *) * mapHeight); it says
error: invalid operands to binary * (have ‘long unsigned int’ and ‘xmlChar *’)
and when I tried this
world->representation = malloc(sizeof(int *) * (int) mapHeight);
I got this error
Undefined symbols for architecture x86_64:
“_main”, referenced from:
start in crt1.10.6.o
“_commandfetcher”, referenced from:
_commandFetcher in ccPv5Pvd.o
ld: symbol(s) not found for architecture x86_64
How can I cast a xmlChar pointer to an int? e.g the xmlChar has the value of 30, I need this in int form.
You can’t simply cast a
charto anint. (Or rather, you can, but it doesn’t do what you think it does.)Use
strtolto convert a string to an integer: