• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

warning C4244 '=' CONVERSION FROM 'LONG ' TO UNSIGNED SHORT' POSSIBLE LOSS OF DATA

//this is C

How can I resolve this warning in C

u_short serverPor
char ans[32];
gets(ans);
serverPort = atol(ans);

warning C4244 '=' CONVERSION FROM 'LONG ' TO UNSIGNED SHORT' POSSIBLE LOSS OF DATA
0
1030071002
Asked:
1030071002
1 Solution
 
SuperdaveCommented:
Try casting it explicitly:

serverPort = (u_short)atol(ans);
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now