wick
wick

Reputation: 2234

conversion to non-scalar type

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?

Upvotes: 2

Views: 920

Answers (1)

ravibhuva9955
ravibhuva9955

Reputation: 199

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.

Upvotes: 2

Related Questions