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   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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 char a[] = "string"; and
char *p = "string"; ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 1
we can not access a++ or a-- on array but we can do that in 
pointers

array, address is constanct for that string, pointer is not 
like that
 
Is This Answer Correct ?    0 Yes 0 No
Singamsa
[Virtusa]
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 2
a is a const pointer, whereas p is not
meaning 'a' will point to a fixed location (value of 'a' or 
address of *a can't change, remains fixed) - though 
contents of a can be changed (by way of accessing a[i])
 
Is This Answer Correct ?    0 Yes 0 No
Srinivas
 
 
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 3
we cannot assign a string to another but we can assign a 
char pointer to another char pointer.
 
Is This Answer Correct ?    0 Yes 0 No
Abc
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 4
char s[]; this allocate memory equal tosize of string
and char *s; holds the address of first charecter
 
Is This Answer Correct ?    0 Yes 0 No
Praveenkumar Managuli
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 5
hi im answering as far as i know , pls say ur feedback,,,(+_+)
Array:
for char array char a[]; no such array size is accepted by
the compiler. That is , it requires a fixed size for the
array  like: char a[20];

in this case the number of strings / characters it can hold
is only upto 20 while if it exceeds , the input strings get
truncated. [STATIC MEMORY ALLOCATION AND TRAVERSAL WITHIN
BOUNDS]

Pointer:
Whereas in case of pointers it is of DYNAMIC MEMORY type and
infinite storage when compared to Array. and predefinition ,
truncation are absent.
Also TRAVERSAL is easy.
 
Is This Answer Correct ?    0 Yes 0 No
Aravind
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 6
Pointers are fine a cannot be changed p can be changed.

I have a doubt like is there any difference in memory
allocation.

I heard like a gets its memory in local stack and p gets in
data section.

I don get the clear explanation
 
Is This Answer Correct ?    0 Yes 0 No
Ashok
 
  Re: What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer
# 7
char a[] will alocate the momery size of " string" word in 
other hand char *p will alocate the memory size of one 
character... or we can not move the data from one location 
to another location but with pointer we can do it...
 
Is This Answer Correct ?    0 Yes 0 No
Parmjeet Kumar
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Program to write some contents into a file using file operations with proper error messages.  1
to find the program of matrix multiplication using arrays  1
What is an volatile variable? HP6
Difference between fopen() and open()? Aricent1
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable) Mascot3
how to find out the reverse number of a digit if it is input through the keyboard?  1
write a c program to check weather a particluar bit is set or not? IBM2
print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5  4
how to find the kth smallest element in the given list of array elemnts. Silicon3
x=2,y=6,z=6 x=y==z; printf(%d",x) HCL7
main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output?? Ramco12
What are advantages and disadvantages of recursive calling ? HP6
Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.  4
What is C language Terminator? TCS12
int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of arr[] Hughes4
Find string palindrome 10marks Honeywell3
How can I invoke another program from within a C program?  1
WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****  2
#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); } ADITI2
what is the maximum no. of bytes calloc can allocate Mphasis2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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