Solved

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

Posted on 2011-03-02
1
549 Views
Last Modified: 2012-05-11
//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
Comment
Question by:1030071002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
Superdave earned 500 total points
ID: 35018782
Try casting it explicitly:

serverPort = (u_short)atol(ans);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question