Bloomberg LP Interview Question for Financial Software Developers






Comment hidden because of low score. Click to expand.
3
of 3 vote

Can be done:
str is a changeable pointer to a constant char
can change the pointer to point to something else
str = &anotherVairable ;
otherwise, nothing else can be done with it....

- oxymoron May 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

well,to complete the answer

can't do
*str = charValue; can't assign anything to the pointee....

- oxymoron May 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

declares a pointer that points to a constant char.

- Anonymous May 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char *const c // constant pointer to char
char const* c // pointer to const char
const char* c // pointer to const char

- Anonymous August 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

It defines a pointer str can be used to point to a constant char data.We can modify the data that the pointer str pointing to.However,each time we need to give it a const char data.We can not modify the value of the data using str because str can only be used to point to a constant data which means it can not be modified.

- yingdi1111 November 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Correction.I mean it like this.

str = &onechar;
str = &secondchar;

However, we can not do it like this.

*str = thirdchar;

This is not allowed.
I hope it is clear now.

- yingdi1111 November 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just like normal variables, pointers can be declared constant. There are two different ways that pointers and const can be intermixed, and they are very easy to mix up.

To declare a const pointer, use the const keyword between the asterisk and the pointer name:

int nValue = 5;
int *const pnPtr = &nValue;
Just like a normal const variable, a const pointer must be initialized to a value upon declaration, and its value can not be changed. This means a const pointer will always point to the same value. In the above case, pnPtr will always point to the address of nValue. However, because the value being pointed to is still non-const, it is possible to change the value being pointed to via dereferencing the pointer:

*pnPtr = 6; // allowed, since pnPtr points to a non-const int
It is also possible to declare a pointer to a constant variable by using the const before the data type.


int nValue = 5;
const int *pnPtr = &nValue;
Note that the pointer to a constant variable does not actually have to point to a constant variable! Instead, think of it this way: a pointer to a constant variable treats the variable as constant when it is accessed through the pointer.

Thus, the following is okay:


nValue = 6; // nValue is non-const
But the following is not:

1
*pnPtr = 6; // pnPtr treats its value as const
Because a pointer to a const value is a non-const pointer, the pointer can be redirected to point at other values:

int nValue = 5;
int nValue2 = 6;

const int *pnPtr = &nValue;
pnPtr = &nValue2; // okay
To summarize:

A non-const pointer can be redirected to point to other addresses.
A const pointer always points to the same address, and this address can not be changed.
A pointer to a non-const value can change the value it is pointing to.
A pointer to a const value treats the value as const (even if it is not), and thus can not change the value it is pointing to.
Finally, it is possible to declare a const pointer to a const value:

const int nValue;
const int *const pnPtr = &nValue;
A const pointer to a const value can not be redirected to point to another address, nor can the value it is pointing to be changed.

Const pointers are primarily used for passing variables to functions. We will discuss this further in the section on functions.

- isandesh7 February 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

That's just a constant variable that hold reference to a character. You can't do anything with it since it's not declare.

- Tommy March 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nopes !! The thing which you are talking about is char *const str;

- Seth June 29, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nopes !! The thing which you are talking about is char *const str;

- Seth June 29, 2011 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More