answersLogoWhite

0

Can you make an integer pointer variable to char data?

Updated: 8/18/2019
User Avatar

Wiki User

13y ago

Best Answer

Of course. But why?

int *p = (int *)"string";

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you make an integer pointer variable to char data?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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.


Can a pointer to char data-type be type casted to pointer to integer type?

Yes it is possible in C language.includeint main(void) { char *cptr; int *iptr; iptr=(int*)cptr; return 0; }If you find the info useful Please Vote!!!


What is the default data type for Visual Basic?

A variable has a data type such as integer, string, double. A data type tells the variable to only store values that are a particular data type, so you can only store numbers without decimal points in an integer variable, and only characters such as "ABCD" in a string variable.


What is the purpose of the dereference operator when used with a pointer variable?

Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array


Why you use float pointer instead of integer pointer?

It depends on what type of data you wish to manipulate.


What is a valid variable data type?

1. If its natural or integer numbers- Integer(Int) data type. 2. If it consists of decimal or fraction part- Double or float data type. 3. If it has a single letter or sign- Character(Char) data type. 4. If its got many words(alpha-numerical)- String data type. 5. If the result has to be "true" or "false"- Boolean data type.


How do you convert char array into unsigned char array in c?

You can't convert the data type of any variable.


Difference between void pointer and null pointer?

A Null pointer has the value 0. void pointer is a generic pointer introduced by ANSI. Before ANSI, char pointers are used as generic pointer. Generic pointer can hold the address of any data type. Pointers point to a memory address, and data can be stored at that address.


What is poiner value in c?

In c a pointer is a variable that points to or references a memory location in which data is stored. Each memory cell in the computer has an address that can be used to access that location so a pointer variable points to a memory location we can access and change the contents of this memory location via the pointer. Pointer declaration A pointer is a variable that contains the memory location of another variable. The syntax is as shown below. You start by specifying the type of data stored in the location identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you give the name of the variable. type * variable name Example: int *ptr; float *string;


When would you use a pointer and a reference variable?

pointer: to access data by address reference: there is no reference in C language


Is class a pointer?

No. In computer programming, a class is a data type while a pointer is a variable that can store a memory address.


What does bus error mean?

bus error is caused mainly due to the misaligned data members i.e if int starts at an odd memory location then accessing it as int would cause bus error. Trival example for this is, allocating memory for integer pointer and trying to access the region with char pointer.