Login
Register
@
Dark Mode
Profile
Edit my Profile
Messages
My favorites
Register
Activity
Q&A
Questions
Unanswered
Tags
Subjects
Users
Ask
Previous Years
Blogs
New Blog
Exams
Dark Mode
self doubt
nag.swarna
asked
in
Programming in C
Sep 2, 2018
634
views
0
votes
0
votes
what is the difference between
*(ptr)++ and ptr++ where char *ptr="gateoverflow"
pointers
nag.swarna
asked
in
Programming in C
Sep 2, 2018
by
nag.swarna
634
views
answer
comment
Follow
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
2
Answers
1
vote
1
vote
Best answer
ptr++ will make the pointer to point to 'a' in the string array. Initially,it was pointing to 'g'.
Wheras, *(ptr)++ will dereference the value at location pointed by pointer.i.e 'a'(dereference).
Vivekk
answered
Sep 2, 2018
selected
Sep 2, 2018
by
nag.swarna
by
Vivekk
comment
Follow
share this
0 Comments
Please
log in
or
register
to add a comment.
0
votes
0
votes
Here "precedence" is the key to understand this. Precedence of ' ++ ' is more than the deferencing operator ' * '. So putting () increases the precedence of * over ++. So, in 1st case *(p)++ it will print the next alphabet of g in ASCII sequence i.e ' h ' whereas in 2nd case *p++ will first increment the pointer then will access the value of the incremented position i.e ' a ' for string "gateoverflow".
ARIJIT SARKAR
answered
Sep 2, 2018
by
ARIJIT SARKAR
comment
Follow
share this
4 Comments
Show 2 previous comments
by
Nitesh Choudhary
commented
Sep 5, 2018
reply
Follow
share this
#include <stdio.h>
int main()
{
char *ptr="gateover";
*(ptr)++;
printf("%c",*ptr);
return 0;
}
o/p=== a
#include <stdio.h>
int main()
{
char *ptr="gateover";
*ptr++;
printf("%c",*ptr);
return 0;
}
op=a
in both the case op is same
0
0
by
Kaluti
commented
Sep 7, 2018
reply
Follow
share this
It means both expression evaluates to same
0
0
by
Nitesh Choudhary
commented
Sep 8, 2018
reply
Follow
share this
Yes
() Doesn't change the priority or precedence
0
0
Please
log in
or
register
to add a comment.
← Previous
Next →
← Previous in category
Next in category →
Related questions
1
vote
1
vote
1
answer
1
srestha
asked
in
Programming in C
May 5, 2019
837
views
Array of Pointers-Self Doubt
$1)$ How to access array element with array of pointers? By pointer to an array we can access like this $(*a)[0]$,$(*a)[22]$, .. like this right? but how with array of pointer? $2)$Check these three codes , one of them use array and one of them use ... main(void) { if(*(ptr+5)==*(ptr+3)){ printf("Equal"); } else{ printf("Not Equal"); } return 0; }
srestha
asked
in
Programming in C
May 5, 2019
by
srestha
837
views
pointers
programming-in-c
1
vote
1
vote
1
answer
2
Na462
asked
in
Programming in C
Jan 8, 2019
1,413
views
Output of following program(Self Doubt)
#include <stdio.h> main (){ unsigned x = -10; int X = 20; if (X > x) printf ("Hello"); else{ printf ("%d",x); printf ("Jello"); } }
Na462
asked
in
Programming in C
Jan 8, 2019
by
Na462
1.4k
views
programming-in-c
output
pointers
0
votes
0
votes
1
answer
3
eyeamgj
asked
in
Programming in C
Oct 3, 2018
489
views
self doubt
++*p and (*p)++ both are same????
eyeamgj
asked
in
Programming in C
Oct 3, 2018
by
eyeamgj
489
views
programming-in-c
pointers
self-doubt
1
vote
1
vote
2
answers
4
Shubhanshu
asked
in
Programming in C
Jun 10, 2017
1,562
views
Self Doubt In String C-Programming
#include <stdio.h> void my_toUpper(char* str, int index) { *(str + index) &= ~32; } int main() { char* arr = "gatesquiz"; my_toUpper(arr, 0); my_toUpper(arr, 5); printf("%s", arr); return 0; } (a) GatesQuiz (b) gatesquiz (c) Compiler dependent
Shubhanshu
asked
in
Programming in C
Jun 10, 2017
by
Shubhanshu
1.6k
views
programming-in-c
strings
pointers
Subscribe to GATE CSE 2024 Test Series
Subscribe to GO Classes for GATE CSE 2024
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
-tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
Post GATE 2024 Guidance [Counseling tips and resources]
GATE CSE 2024 Result Responses
[Project Contest] Pytorch backend support for MLCommons Cpp Inference implementation
Participating in MLCommons Inference v4.0 submission (deadline is February 23 12pm IST)
IIITH PGEE 2024 Test Series by GO Classes
Subjects
All categories
General Aptitude
(3.5k)
Engineering Mathematics
(10.4k)
Digital Logic
(3.6k)
Programming and DS
(6.2k)
Programming
(4.1k)
Programming in C
(4.1k)
Programming in Python
(5)
DS
(2.0k)
Algorithms
(4.8k)
Theory of Computation
(6.9k)
Compiler Design
(2.5k)
Operating System
(5.2k)
Databases
(4.8k)
CO and Architecture
(4.0k)
Computer Networks
(4.9k)
Artificial Intelligence
(79)
Machine Learning
(48)
Data Mining and Warehousing
(25)
Non GATE
(1.4k)
Others
(2.7k)
Admissions
(684)
Exam Queries
(1.6k)
Tier 1 Placement Questions
(17)
Job Queries
(80)
Projects
(11)
Unknown Category
(870)
64.3k
questions
77.9k
answers
244k
comments
80.0k
users
Recent Blog Comments
category ?
Hi @Arjun sir, I have obtained a score of 591 in ...
download here
Can you please tell about IIT-H mtech CSE self...
Please add your admission queries here:...
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy