ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
what is the difference between these initializations? 
Char a[]=”string”; 
Char *p=”literal”; 
Does *p++ increment p, or what it points to?
 Question Submitted By :: A. Sujatha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?
Answer
# 1
surely there is some difference.....

here 'a' is represented as array in which string gets stored
in consecutive locations......

p is a pointer variable where string is initilized... so in
p the base address of "literal " will get stored...... 

*p++ increments 'p' , but pertaining to some conditions.....
++ has more precedence than * , so first it will increment
the address and correspondingly it will show the value as *
precedes..... so after the increment the p points to 'i'...



thank u
 
Is This Answer Correct ?    2 Yes 0 No
Vignesh1988i
 
  Re: what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?
Answer
# 2
I am totally satisfied with your above explanation except
last one. 
i.e.  Char *p="literal";
So, i want to mention yes this will work.
Explanation: *p++. 
Here we have post increment. 
Postfix increment/decrement have high precedence, but the
actual increment or decrement of the operand is delayed (to
be accomplished sometime before the statement completes
execution).
value of printf("\nstr=%c\n",*p++) will be 'l', but before
complete execution of this statement p will point to string
"iteral" as p got incremented.
 
Is This Answer Correct ?    1 Yes 0 No
Gaurav
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the differnce between AF_INET and PF_INET? Wipro2
write a program for even numbers?  8
for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????  6
Total of how many functions are available in c?  2
What is memmove? Oracle1
What is the diffrent between while and do while statement ?  5
how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0 Wipro3
What are Storage Classes in C ? HP14
What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1; TCS10
differentiate between const char *a; char *const a; and char const *a; HCL1
write a program to find the number of even integers and odd integers in a given array in c language Olive-Tech2
what is the difference between strcpy() and memcpy() function?  1
how to generate sparse matrix in c  1
difference between i++* and *++i IBM3
write a recursive program in'c'to find whether a given five digit number is a palindrome or not  1
what is the size of an integer variable?  1
i want to have a program to read a string and print the frequency of each character and it should work in turbo c  2
Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++; ITCO3
related to rdbms query .  1
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.  4
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com