Search code examples
ccastingatoiint32

How cast type int with atoi() to Int32


I've got a piece of C code:

Int32 tmp = atoi("314");

It throws an error:

error: Int32 undeclared (first use in this function)

I have no idea why? Could you help me?

Maybe it is problem with #includes:

  • sys/socket.h
  • netinet/in.h
  • arpa/inet.h
  • stdio.h
  • stdlib.h
  • string.h
  • strings.h

Solution

  • There is no standard type called Int32. You're probably looking for

    int tmp = atoi("314");
    

    If you need a 32-bit integer, the standard type is int32_t defined in inttypes.h or stdint.h.