Domanda

This line will compile fine:

memcpy(&rp.iplow, &((struct sockaddr_in*) &dstl)->sin_addr, 4);

whereas what I originally coined it as:

memcpy(&rp.iplow, &((struct sockaddr_in) dstl).sin_addr, 4);

will say error: conversion to non-scalar type requested

Shall I conclude that one cannot use struct types for casting whatsoever?

È stato utile?

Soluzione

Yes you are able to conclude that structure types are not able to cast directly. So you must need to type cast it as shown in first line written by you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top