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
What's the right way to use errno?
What is difference between union and structure in c?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What are the different types of linkage exist in c?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is dangling pointer in c?
Which is more efficient, a switch statement or an if else chain?
What is the code in while loop that returns the output of given code?
What are conditional operators in C?
Differentiate fundamental data types and derived data types in C.
write a program to generate address labels using structures?
What Is The Difference Between Null And Void Pointer?
Why is c so popular?
How many header files are in c?