type « Cast « C Q&A

Home
C Q&A
1.assembly
2.buffer
3.Card
4.Cast
5.compile
6.console
7.const
8.constructor
9.database
10.Date
11.Debug
12.Design
13.Development
14.DLL
15.encrypt
16.enum
17.eof
18.Event
19.fork
20.Format
21.gcc
22.gdb
23.graph
24.graphics
25.gui
26.Holiday Event
27.image
28.IP
29.iterator
30.macro
31.makefile
32.malloc
33.Menu
34.mysql
35.network
36.openssl
37.operator
38.password
39.pipe
40.preprocessor
41.printf
42.pthread
43.Regular expression
44.scanf
45.semaphore
46.SerialPort
47.server
48.Socket
49.sql
50.SQLserver
51.sscanf
52.std
53.stdin
54.stdout
55.stl
56.strcmp
57.stream
58.switch
59.Template
60.thread
61.timer
62.unix
63.video
64.Virtual
65.visualstudio
66.winapi
67.windows
68.xml
C Q&A » Cast » type 

1. Understanding type casting in c    stackoverflow.com

I'm following a book on c, and I come to some code that reads a file with 3 lines of text.

#include <stdio.h>

int main (int argc, const char * argv[]) {
  ...

2. Casting in mixed type calculations in C?    stackoverflow.com

If I define these variables:

double x0, xn, h;
int n;
and I have this mathematical expression:
h = (xn - x0)/n;
Is it necessary that I cast n into double prior doing the division for ...

3. C type casts and addition precedence    stackoverflow.com

What's the precedence in the next expression?

item = (char*)heap + offset;
Is it (char*)(heap + offset) or ((char*)heap) + offset?

4. Type casting, c language problem    stackoverflow.com

I'm not able to understand some typecasting syntaxes. For eg.

float f=7.0;
short s=*(short *)&f;
What's happening here short s=*(short *)&f? Looks like we're casting something as a pointer to a short and then ...

5. why do we type-cast?    stackoverflow.com

If I do:

int i=3, j=10;
float f;
f=(i+j)/2;
so f won't get value 6.5 but 6.
But,
f=(i+(float)j)/10;//edited 
would be f=6.5. What is the place where this temporary values are stored and why do we need to ...

6. what happens while type casting to a different data type    stackoverflow.com

why is the output fffffffa rather than 0000000a for this code

char c=0Xaa;
     int b=(int)c;
     b=b>>4;
     printf("%x",b);
what i thought was ...

7. Noob Q: How to properly type cast in this case    bytes.com

Hi, I couldn't figure out how to properly type cast in this case: $ cat -n type_cast.c 1 #include 2 3 typedef unsigned char Byte; 4 typedef signed char Small_Int; 5 6 typedef struct _list 7 { 8 struct _list *np; /* Pointer to next */ 9 struct _list *lp; /* Pointer to last */ 10 Byte type; 11 union ...

8. Q) Identifying the correct data type at run time (RTTI anddynamic_cast)    bytes.com

Generic Usenet Account I ran a small experiment involving RTTI and dynamic casting. Basically what I did was to cast a base class pointer to a derived type (yes, I know that is not kosher). I then performed dynamic_casting and I invoked RTTI. In both instances, the run time environment did not pick up the fact that what I was claiming ...

9. Type-punning / casting problem    bytes.com

Phil Endecott Dear Experts, I need a function that takes a float, swaps its endianness (htonl) in place, and returns a char* pointer to its first byte. This is one of a family of functions that prepare different data types for passing to another process. I have got confused by the rules about what won't work, what will work, and what ...

10. Use a suffix or a type cast?    bytes.com

Hi I am interested in opinions on this topic. I have heard that a suffix is not a good solution and type casts are much better for example. ----------------------------------------------------------------- #define MAX_UWORD (T_UWORD)65535 or #define MAX_UWORD 65535u ------------------------------------------------------------------- Where UWORD is unsigned short int. What is your opinion? or why would someone have said using a suffix is no good? For starters ...

11. type casting    bytes.com

Hello, All! Given the sample piece of code I have: #include #include int main(void) { short int i, j; int k; i = j = 10; k = i + j; return 0; } So, here I expect that 'i' and 'j' will be type-casted to 'int' type, while in debugger (exploring memory dump) I see these variables still ...

13. simple question on type casting~    bytes.com

14. Type casting    bytes.com

This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A good way to do this is by example. So I will give an example and please tell me what you think: I have a base class A with a virtual destructor, ...

15. Type Casting Question    cboard.cprogramming.com

If char is unsigned, then it would be okay, but I wonder why you want to do this in the first place. If char is signed, then I believe that "the result is implementation-defined or an implementation-defined signal is raised" since those values most likely do not fall in the range of a char.

16. Help:working of Type casting    cboard.cprogramming.com

17. type casting?    cboard.cprogramming.com

US currency has a nice property in that if you two items X, Y such that X < Z and Y < Z then X + Y <= Z. What this really means is that if you go from the largest denomination to the smallest and give that denomination as much as possible then you've given that amount in as few ...

18. about type casting...    cboard.cprogramming.com

19. What dose this type casting mean??    cboard.cprogramming.com

20. type casting    cboard.cprogramming.com

Every value is made up of a bit pattern and a type. The bit pattern doesn't change, but just a bit pattern isn't useful. The type tells C how to represent the bit pattern. An example is that the bit patten 01000001 represented as an int is 65, but represented as a char it's 'A'. The bit pattern doesn't change, but ...

21. type cast problem    cboard.cprogramming.com

Code: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int max; int min; int interval; int numSize; int i; int *num; int *numSquare; printf( "Enter a minimum value: "); scanf( " %d", &min); printf( "Enter a maximum value: "); scanf( " %d", &max); printf( "Enter an interval: "); scanf( " %d", &interval); //numSize = ((max - min) / interval ) + ...

22. type casting    cboard.cprogramming.com

23. Arguments and type casting    cboard.cprogramming.com

1: /************************************** 2: * cels2fahr.c: 3: * A program that takes an integer as an argument 4: * and converts it from Celsius (C) to Fahrenheit 5: * (F). 6: ************************************/ 7: 8: #include 9: 10: int main(int argc, char *argv[]) { 11: 12: int fahr = 0; 13: 14: if (argc < 2) { 15: printf("Proper Usage: \n"); 16: ...

24. type casting problem?    cboard.cprogramming.com

type casting problem? I am attempting to compile some code that I got in an ISO document for barcode generation. When I try to compile it in MS Visual C++, I get the following error: mappings.cpp(147) : error C2440: '=' : cannot convert from 'void *' to 'int *' I have put the line in question in bold and red below. ...

25. Type casting    cboard.cprogramming.com

Type casting I have a prime number calculator program that uses type casting. The type casting occurs in my "prime_calculator" function, under "Discard remaining composite numbers". If I run it without type casting it, I get an error msg "conversion from double to unsigned long; possible loss of data". I was just wondering where/what is the "double"? mw Code: #include #include ...

26. help with simple type casting problem    cboard.cprogramming.com

27. Data Type Casting    forums.devshed.com

I am working on a Windows platform with VS 2005 C++, but the problem relates to c/c++ in general. I have been trying to interface with a GPS software program which uses a message made up to an 20 word array of unsigned shorts; e.g. unsigned short messageData[20]; I have been trying to use data from a home GPS system which ...

28. Type casting or alternative    forums.devshed.com

I'm assuming the asterix in the first example is an error on your part, as that line will not compile. Your question doesn't make sense because; 1) You haven't specified a type for n (although, of the standard types supported by C, the only types that can represent it are long long types). 2) Although it is possible with some implementations, ...

29. Type cast in c#    forums.devshed.com

hi ,... I have a question about programming with c#,... suppose we have a textbox that receives a number ,.. and we want to use this number in a mathematical operation ,.. as we know, the type given by a textbox is string ,..and thus, we should convert it to an integer value ... how can we convert it's type to ...

30. Type Cast    forums.devshed.com

Ok, this might seem like a really simple quesiton to some.. but its not happenging for me rigth now..maybe due to lack of sleep or stress or being a newbie in C..(yeah.. one of those days ) my code seems to be getting more and more complex.. what I'm trying to do is convert a long to a char a char ...

31. Type casting doubt    forums.devshed.com

Mitakeet is correct, although I'd probably say it differently. Typecasting of a void pointer to any other raw pointer type NEVER invokes a constructor. All typecasting does in this case is force the compiler to treat the void pointer as if it is the desired type --- whether the memory pointed to by the void pointer is actually such an object ...

32. Type casting issue    daniweb.com

33. type casting    daniweb.com

Pointer subtraction takes the size of the type into account. If it's a pointer to char, the size is 1 and with 50 chars the result will be 50. If it's a pointer to int, the size is sizeof(int), and with 50 ints the result will be 50 * sizeof(int). On your system sizeof(int) looks to be 4, and 50 * ...

34. Please help me in Type casting    daniweb.com

35. Type casting and type conversions    daniweb.com

36. Enumeration Casting type error.    codeproject.com

37. Query on type casting.    tek-tips.com

/* Low-level i/o sample */typedef struct Hdr { int x, y; } *Phdr;char buff[100];Phdr p;...if (fread(buff,1,100,f) >= sizeof(struct Hdr)){ p = (Phdr)buff; /* as usually, do nothing (char* bits == p bits) * char[] implicitly casted to char* then your cast... * Now the compiler knows that you know ...

38. Type Casting Question    tek-tips.com

I am having a problem with converting a int to at floating point number. It is my understanding that the converstion should be automatic, but an explicit cast does not help either. This example resultis in Y=0 being displayed. Any explanation would be most appreciated. #include main() { int x; ...

39. type cast    tek-tips.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.