1 Crore+ students have signed up on EduRev. Have you? |
* is used as dereferencing operator, used to read value stored at the pointed address.
Which one of the following is not a possible state for a pointer.
A pointer can be in only 3 states a, b and c.
What will happen in the following C++ code snippet?
int a = 100, b = 200;
int *p = &a, *q = &b;
p = q;
Assigning to reference changes the object to which the reference is bound.
The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________
Function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is int **fun(float*, char**).
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 5;
cout << ptr;
return 0;
}
Pointer ptr points to string ‘fg’. So it prints fg.
Output:
$ g++ point.cpp
$ a.out
fg
The (*fn) represents a pointer to a function and char* as arguments and returning int from the function. So according to that, the above syntax represents a pointer to a function taking a char* as an argument and returning int.
* is to be grouped with the variables, not the data types.
dp is initialized int value of i.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int *arr[ ] = {&a, &b, &c};
cout << arr[1];
return 0;
}
Array element cannot be address of auto variable. It can be address of static or extern variables.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
char arr[20];
int i;
for(i = 0; i < 10; i++)
*(arr + i) = 65 + i;
*(arr + i) = '\0';
cout << arr;
return(0);
}
Each time we are assigning 65 + i. In first iteration i = 0 and 65 is assigned. So it will print from A to J.
$ g++ point1.cpp
$ a.out
ABCDEFGHIJ
15 videos|20 docs|13 tests
|
Use Code STAYHOME200 and get INR 200 additional OFF
|
Use Coupon Code |
15 videos|20 docs|13 tests
|
|
|
|
|
|
|
|
|
|