Solved

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

Posted on 2011-03-02
1
538 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
Comment Utility
Try casting it explicitly:

serverPort = (u_short)atol(ans);
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now