answersLogoWhite

0


Best Answer

Yes it is possible in C language.

  1. include

int main(void) { char *cptr; int *iptr; iptr=(int*)cptr; return 0; }

If you find the info useful Please Vote!!!

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can a pointer to char data-type be type casted to pointer to integer type?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Are pointers integers?

A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.


What does a char store?

In JavaA char in Java is a 16-bit integer, which maps to a subset of Unicode.In C A char in C is an 8-bit integer, which maps to standard ASCII.Note that in both Java and in C you can use a char value like a normal integer type: char c = 48;


How do you declare a pointer to a character string in c?

char *ptr;


Pointer version of string function strcpy?

char* strcpy(const char* src, char* dst) { char* tmp = dst; while ((*dst++ = *src++) != '\0'); return tmp; }


Can you assigned value of int to a ordinary pointer?

Yes, with type-cast (but I don't see why you should): char *ptr = (char *)300;

Related questions

What is the best datatype for storing your birthday?

in Unix: the datatype is "Date" in C++: the datatype is "char"


What is the best datatype for storing birthdays?

in Unix: the datatype is "Date" in C++: the datatype is "char"


Can you make an integer pointer variable to char data?

Of course. But why? int *p = (int *)"string";


Are pointers integers?

A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.


What is the difference between char and varchar data types?

The CHAR datatype uses a fixed length, where as the VARCHAR datatype can be variable in length up to the maximum value specified for the length. If you insert "Hello" into a CHAR(10) field, the column would actually contain "Hello " with 5 trailing spaces. The same value inserted in a VARCHAR(10) field would contain "Hello". char datatype is fixed length data type and it store maximum 255 characters while varchardatatype store up to 4000 character of variable length datatype


What does a char store?

In JavaA char in Java is a 16-bit integer, which maps to a subset of Unicode.In C A char in C is an 8-bit integer, which maps to standard ASCII.Note that in both Java and in C you can use a char value like a normal integer type: char c = 48;


What is primitive variables?

variable declared with primitive datatype are called as primitive variable. ex: short s=12; char ch='a'; here in above case ch,s are declared with primitive datatype of short and char so it is called as primitive variables.. thanx, from rajesh adepu.


Can a pointer be considered a variable?

You can declare pointer-variables, if that's what you mean. Example: char *sample = "Sample";


How do you declare a pointer to a character string in c?

char *ptr;


Data type in data base?

In different languages we have different datatypes . Like in c++ we have int for integers , string for strings . In database we have datatypes, number for storing integer and varchar2 for storing string or characters.Like in languages like c we have datatypes such as char for characters , int for integers etc . In database we have datatype to denote the type of the field example numbers for storing integer, Varchar for characters.


Pointer version of string function strcpy?

char* strcpy(const char* src, char* dst) { char* tmp = dst; while ((*dst++ = *src++) != '\0'); return tmp; }


What is declaring pointer variable?

I'll give you an example: char *s;