answersLogoWhite
Computer Programming
C Programming
How To

How to multiply two int pointer variable in C language?

91011

Top Answer
User Avatar
Wiki User
Answered
2009-08-07 20:08:37
2009-08-07 20:08:37

You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *

001
๐Ÿฆƒ
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0

Related Questions


A pointer is a variable which is used to store address of a variable. They are used to point to another variable.eg:-int *p; // creates a pointer of integer typeint num; // an integer variablep=# //pointer variable p is assigned with address of num


int* pint; // instantiate a pointer to an int. float* pflt; // instantiate a pointer to a float.


A pointer to pointer variable can hold the address of another pointer variable. The Syntax is as follow: type** variable; Example:: //function prototype void func(int** ppInt); int main() { int nvar=2; int* pvar=&nvar; func(&pvar); .... return 0; }One more important use of pointer-to-pointer is for creating multi-dimensional array dynamically, see See the related links.


With a * For example: int *pointerToInt;


Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


Double (**) is used to denote the double pointer. As we know the pointer stores the address of variable, Double pointer stores the address of any pointer variable. Declaration : int **ptr2Ptr;


Assigning an initial value to a pointer variable. Example: int *p= NULL;


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


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


#include<iostream> int main() { int x=42; int* p=&x; // declare and initialise a pointer, assigning the address of x. }


The dereference operator. In C, we use the * operator for this. Note that the * symbol has several meanings in C (multiplication, pointer declaration and pointer dereferencing). The meaning is determined from the context in which it is used. int x, y; /* integer variables */ int* p; /* pointer variable (pointer to int) */ x = 42; /* assign a value to the x variable */ p = &x; /* assign the address of the x variable to the pointer variable p */ y = *p; /* assign the value pointed to by p (42) to the variable y */


normal variable stores a value of the given datatype where as the pointer variable stores the address of a variable. for example int n=10; int *p; p=&n; here p is a pointer variable and n is a normal variable.p stores the address of n where as n stores an integer value. *p prints the value of n,p prints the address of n.


A pointer is a variable that holds an address in memory. int * pPointer = new int; This code creates a pointer to an integer, and assigns it an address of an integer object on the heap.


variable = value; example: int n, *p; p= &n;


I have no idea what you mean by that... Some examples for pointers of different types: int *intptr; char *charptr; void *generic_ptr; FILE *stdin; int (*funptr)(int, char **);


int a; -- variable definition"int a" -- string literal


Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer



Pointer is a variable which store address of an other variable. To declare a pointer variable <syntax>: <data-type> *<variable-name>; example: int *x; now x will store an address. to find the address of any variable we use '&' in c. example: int y; then address of y is &y; but now x will store only address : x= &y; here x= address of variable and *x = value at the variable.


int *x,*y; int a=14,b=10; x=&a; y=&b; printf(the variable and address of the variable a is %d", a,*x);


swap (int *a, int *b) { *a ^= *b; *b ^= *a; *a ^= *b; }


I presume you referring to the C pointer syntax where an asterisk operator may be suffixed to a type or prefixed to a variable. The following may help to clarify: int*p; int* q; int *r; int * s; All four of these declarations are exactly the same (they are all pointer-to-int variables). Note that the physical position of the asterisk operator makes no difference whatsoever, no matter how much whitespace you use (whitespace is essentially ignored both before and after an operator). Because the type is pointer-to-int, it usually makes sense to use the second variant to separate the variable's type from its name. However, this doesn't really work when declaring multiple pointer variables of the same type on the same line using the comma operator. Consider the following: int* p, q, r, s; While it is natural to assume p, q, r and s are all pointer-to-int types, they are not. The first, p, is the only pointer-to-int type, while all the others are just plain int types. If we really want 4 pointer-to-int types, we need to use the following declaration instead: int *p, *q, *r, *s;


float *(*funptr)(int *); float *fun (int *); funptr= fun;


A pointer in C is a pointer. Examples: int *intptr; char *charptr; int (*funptr)(int, char **);


Pointers store the addresses of other variables (primitive data-types, user-defined data-types (like structures and classes), as well as other pointers (in the case of a pointer to a pointer)). On the other hand, ordinary variables simply store data values. A pointer must be dereferenced using the * operator to refer to its data value. For example, int a; // this is an ordinary variable int *p = &a; // this is a pointer to the integer variable a In the above example the & symbol is the address-of operator. It returns the address of variable a.



Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.