• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Live Q & A: Securing Your Wi-Fi for Summer Travel

Traveling this summer? Join us on June 18, 2018 for a live stream to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

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