When should a type cast not be used?



When should a type cast not be used?..

Answer / Hari Ram Meena

A type cast should not be used when it may lead to an undefined behavior or runtime error. For example, casting a larger data type to a smaller one without checking if the value being cast can fit in the smaller data type.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

How does C++ help with the tradeoff of safety vs. usability?

1 Answers  


int far *near * p; means

1 Answers   Honeywell,


What are the two types of structure?

1 Answers  


write a program to convert a expression in polish notation (postfix) to inline (normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix

0 Answers  


What is wrong with this initialization?

1 Answers  


What is the difference between procedural and functional programming?

1 Answers  


Find errors (1) m = ++a*5; (2) a = b ++ -c*2; (3)y = sqrt (1000);

5 Answers  


Differentiate between static and dynamic modeling.

1 Answers   Wipro,


I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....

2 Answers  


Explain argument and its types.

1 Answers  


for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????

8 Answers  


if array a conatins 'n' elements and array b conatins 'n-1' elements.array b has all element which are present in array a but one element is missing in array b. find that element.

18 Answers   Parexel, Ram Infotech, Zycus Infotech,


Categories