This is a discussion on Is this Program Correct within the C and C++ forums, part of the Programming Talk category; I have a doubt about typecasting in C. I have the below code written in my program #include <stdio....
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Is this Program Correct
I have a doubt about typecasting in C. I have the below code written in my program
#include <stdio.h> main() { int x = 101; char y; y = x; } Is the above code correct that will C do automatic typecasting as assumed above in my code or do programmers have to do typecasting explicitly? If so I have to change my code. Kindly clarify my doubt? |
|
|||
|
This will not get automatically typecast as you have mentioned in your program. Automatic typecasting takes place in C but not as you have mentioned. Say for instance you have placed a variable x in a if statement then depending on the value of variables as 0 or 1 the conditional takes up status as false or true respectively. Whenever data type need to be changed you must use explicit typecasting in C programming language with the data type mentioned in brackets.
|
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-15-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:01 AM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 05-15-2004 07:00 AM |
| Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 | rubywand@swbell.net | Tech FAQ | 0 | 04-04-2004 08:29 AM |