سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top