IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Typedef - Discussion

@ : Home > C Programming > Typedef > General Questions - Discussion

Read more:

"The secret to creativity is knowing how to hide your sources."
- Albert Einstein
2. 

In the following code what is 'P'?

typedef char *charp;
const charp P;

[A]. P is a constant[B]. P is a character constant
[C]. P is character type[D]. None of above

Answer: Option C

Explanation:

No answer description available for this question.


Jothi Basu said: (Sat, Aug 14, 2010 02:19:32 AM)    
 
P is a character constant using pointer.

Ashok G said: (Fri, Aug 20, 2010 05:30:13 AM)    
 
I guess P is a pointer to a const char.

Vinay said: (Mon, Oct 18, 2010 05:19:38 AM)    
 
P is a character constant.

Shweta Dubey said: (Tue, Oct 26, 2010 06:56:50 AM)    
 
P is a pointer to a constant

Kumaran said: (Sun, Nov 14, 2010 01:57:40 PM)    
 
P is the constant... It defined in the outside of main function.

Sunil said: (Sat, Dec 4, 2010 11:03:09 AM)    
 
here p is constant bcz of usage of keyword const

Santhosh said: (Mon, Jan 31, 2011 02:21:38 AM)    
 
her p is a pointer to a constant character

Hngn said: (Tue, Feb 8, 2011 04:38:44 AM)    
 
p is constant chracter pointer

Vikas Sharma said: (Wed, Feb 16, 2011 12:28:06 PM)    
 
P is a constant pointer.

Ana said: (Sat, Mar 19, 2011 02:09:43 PM)    
 
The answer is no clear to me. Can some one please explain.

Wikiok said: (Sun, Apr 10, 2011 02:48:01 PM)    
 
typedef char *charp;
const charp P;

so:
const char *P; // The value can not be changed at that memory location, but other memory locations can be used for *P.
*P=4; //ERROR
P=&a; //Works char a;

Lol said: (Fri, May 6, 2011 03:43:08 AM)    
 
The trick with const modifier is to read the statement backwards.

const charp P = const char *P;

So reading backwards you have P * char const
which is P is a pointer to a char constant.

Rocky said: (Sun, Jul 24, 2011 01:34:15 AM)    
 
p is constant or p is character constant???
please answer!!!!

Ravi said: (Wed, Sep 21, 2011 05:01:55 PM)    
 
P is a pointer to a constant.

Because,

Const char *p;.

Ganga said: (Sun, Dec 4, 2011 09:45:12 PM)    
 
const char *P; // The value can not be changed at that memory location, but other memory locations can be used for *P.
*P=4; //ERROR
P=&a; //Works char a;

Asd said: (Mon, Dec 12, 2011 07:34:04 PM)    
 
I think finally answer is p is a pointer to a character constant which is not in option so anwer is d.

Rupinderjit said: (Thu, Jan 5, 2012 02:21:35 PM)    
 
p can't be pointer, since with typedef we can't modify the actual base type,we just only give new name to existing type. That's all folks.

Lijina said: (Tue, Jan 24, 2012 11:25:51 AM)    
 
Option A is Right,

1. typedef char *charptr;

So charptr contain one address and *charptr contain any constant;

2. const charptr p;

If p='a' and &p=0x10;
Now charptr contain &p(0x10)

Only for address we are keeping const, not for value in that address. So P that is constant.

Write your comments here:
Name *:     Email:


© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!