Solved

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

Posted on 2011-03-02
1
543 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

808 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