what is the difference between these initializations?
Char a[]=”string”;
Char *p=”literal”;
Does *p++ increment p, or what it points to?

Answer Posted / bee

logically, both are treated as array of characters(i.e.
string) but....

1) a is an array of characters(a string)

2) p is a pointer to an array of characters
the statement char *p = "literal" is equivalent to
char j[] = "literal"
char *p = j;
3) *p++ can be seen as *(p++)....
this is so because '++' has higher recedence over '*'
operator. so, it increments address by 1 unit and prints
the corresponding value value

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does double pointer mean in c?

800


Explain what are reserved words?

854


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

2810


Explain enumerated types.

813


What is the time and space complexities of merge sort and when is it preferred over quick sort?

891


What is the scope of static variables in c language?

869


hi send me sample aptitude papers of cts?

1912


What are control structures? What are the different types?

860


Define recursion in c.

965


Can we assign string to char pointer?

825


What is the heap in c?

860


Define macros.

1050


Write a program to identify if a given binary tree is balanced or not.

934


Is it possible to have a function as a parameter in another function?

854


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

857