Hi all,
What is difference between typecasting and casting? I used to think
that both are same; but few days back someone pointed out here that
these are different. Vague guess, Is it that typecasting means casting
using typedef? I just want to confirm it.
Thanks,
Nishu 6 3211
Nishu wrote:
Hi all,
What is difference between typecasting and casting? I used to think
that both are same; but few days back someone pointed out here that
these are different. Vague guess, Is it that typecasting means casting
using typedef? I just want to confirm it.
The official term is a cast. An unofficial term is a typecast. I'm not
aware of any other differences.
Nishu said:
Hi all,
What is difference between typecasting and casting?
A cast is an explicit conversion, so casting is the act of performing an
explicit conversion. For example, int *p = &i; printf("%p\n", (void
*)p); explicitly converts p into a void * to make it suitable for
matching the %p format specifier.
Typecasting, on the other hand, is what happens to an actor when they're
given the same kind of part over and over. For example, Christopher Lee
always seems to get to be the villain.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nishu wrote:
Hi all,
What is difference between typecasting and casting? I used to think
that both are same; but few days back someone pointed out here that
these are different. Vague guess, Is it that typecasting means casting
using typedef? I just want to confirm it.
I think, in C atleast, the more precise term is cast. The act of
making a cast is called casting. It's often used only for explicit
casts, i.e. those that you explicitly write in the source. Implicit
casts, i.e. those that happen due to the rules of C for evaluating
expressions, are probably better called as implicit conversions.
"santosh" <sa*********@gm ail.comwrites:
Nishu wrote:
>What is difference between typecasting and casting? I used to think that both are same; but few days back someone pointed out here that these are different. Vague guess, Is it that typecasting means casting using typedef? I just want to confirm it.
I think, in C atleast, the more precise term is cast. The act of
making a cast is called casting. It's often used only for explicit
casts, i.e. those that you explicitly write in the source. Implicit
casts, i.e. those that happen due to the rules of C for evaluating
expressions, are probably better called as implicit conversions.
I would state it more strongly than that. A cast is an operator that
explicitly specifies a conversion. There are implicit conversions,
but there's no such thing as an "implicit cast".
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On 16 Feb 2007 04:01:14 -0800, "santosh" <sa*********@gm ail.comwrote
in comp.lang.c:
>
Nishu wrote:
Hi all,
What is difference between typecasting and casting? I used to think
that both are same; but few days back someone pointed out here that
these are different. Vague guess, Is it that typecasting means casting
using typedef? I just want to confirm it.
I think, in C atleast, the more precise term is cast. The act of
making a cast is called casting. It's often used only for explicit
casts, i.e. those that you explicitly write in the source. Implicit
casts, i.e. those that happen due to the rules of C for evaluating
expressions, are probably better called as implicit conversions.
I know that Keith already responded, but I don't think he was detailed
enough.
C allows conversions of some types to others. Some of these
conversions are automatic, happening in the course of evaluating an
expression, performing an assignment, or passing an argument to a
prototyped function. Other casts require the use of a cast operator.
Since the only thing that performs a cast is a conversion operator,
all casts are explicit. There is no such thing as an "implicit cast",
but there is an "implicit conversion".
The first sentence of 6.3 Conversions of the C standard describes this
concisely:
"Several operators convert operand values from one type to another
automatically. This subclause specifies the result required from such
an implicit conversion, as well as those that result from a cast
operation (an explicit conversion)."
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:C-*************** *************** @bt.com...
Nishu said:
>Hi all,
What is difference between typecasting and casting?
A cast is an explicit conversion, so casting is the act of performing an
explicit conversion. For example, int *p = &i; printf("%p\n", (void
*)p); explicitly converts p into a void * to make it suitable for
matching the %p format specifier.
Typecasting, on the other hand, is what happens to an actor when they're
given the same kind of part over and over. For example, Christopher Lee
always seems to get to be the villain.
hahaha, here i thought there was a difference This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kapil Khosla |
last post by:
Hi,
I have been trying to understand this concept for quite sometime now
somehow I am missing some vital point. I am new to Object Oriented
Programming so maybe thats the reason.
I want to understand what is typecasting in C++. Say I have a Base
class and a Derived class, I have a pointer to an object to each.
Base *ba = new Base;
Derived *de = new Derived;
|
by: Robert Street |
last post by:
Hi!
I'm rather new at c++ and I'm totally confused with this kind of
typecasting:
typedef signed char int8_t;
typedef signed short int16_t;
typedef struct broadcast_hdr
{
|
by: Niklaus |
last post by:
Hi,
I would like to know more about casts.What exactly happens
when casts are applied to a variable.I know that if an
object of type int is applied an cast of float the result
would be of type float.
1)
What i would like to know is the about the
internals when a cast is applied ? Say we have
|
by: andynaik |
last post by:
Hi,
Whenever we type in this code
int main()
{
printf("%f",10);
}
we get an error. We can remove that by using #pragma directive t
direct that to the 8087. Even after that the output is 0.00000 and no
10.0000. Can anybody tell me why it is like that and why typecasting i
not done in this case?
|
by: Abhishek |
last post by:
why do I see that in most C programs, pointers in functions are
accepted as:
int func(int i,(void *)p) where p is a pointer or an address which is
passed from the place where it is called. what do you mean by pointing
to a void and why is it done?
Aso, what happens when we typecast a pointer to another type. say for
example int *i=(char *)p;
under different situations? I am kind of confused..can anybody clear
this confusion by clearly...
| |
by: Mark Fink |
last post by:
I try to port a server application to Jython. At the moment I use
Jython21\Lib\socket.py
Currently I do face problems with casting the string "localhost" to the
desired value:
D:\AUT_TEST\workspace\JyFIT>jython fit/JyFitServer2.py localhost 1234
23
localhost
Traceback (innermost last):
File "fit/JyFitServer2.py", line 146, in ?
|
by: WittyGuy |
last post by:
How to typecast a "function pointer" to "const void*" type in C++ way?
int MyFunction (double money); // Function prototype
const void* arg = (const void*)MyFunction; // type casting function
pointer to const void* in C-style
void(*pFunc)() = (void(*)())(arg); // type casting const void* to function
pointer in C-style
(*pFunc)(); // Calling the function after type casting is done
|
by: bwaichu |
last post by:
What is the best way to handle this warning:
warning: cast from pointer to integer of different size
I am casting in and out of a function that requires a pointer type. I
am casting an integer as a pointer, but the pointer is 8 bytes while
the integer is only 4 bytes.
Here's an example function:
|
by: weg22 |
last post by:
Hi all,
I'm having problems trying to type cast in VB.Net. I'd like to read
in a 16 bit unsigned integer and convert it to a signed 16 bit
integer. I'm using the following line of code:
Dim wordVal As Short
wordVal = CShort(Val(input.Text))
output.Text = wordVal
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |