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
The C Programming Language .Dennis Ritchie( Character pointers and functions)
Manu FG
asked
in
Programming in C
May 21, 2017
retagged
Jun 4, 2017
by
Arjun
1,282
views
0
votes
0
votes
/*strcpy"copy t to s; */
void strcpy(char *s, char *t)
{
while((*s++=*t++) !='\0');
}
Can anyone explain how *s++ or *t++ is being executed. As * and ++ are unary operators here , they will have same precedence. Unary operators having same precedence are executed from right to left(right associative). So here if we take *s++ is the increment operator being executed first or the dereferencing operator?. Can anyone show the steps of executing this function.
programming-in-c
pointers
Manu FG
asked
in
Programming in C
May 21, 2017
retagged
Jun 4, 2017
by
Arjun
by
Manu FG
1.3k
views
answer
comment
Follow
share this
share
3 Comments
by
akash.dinkar12
commented
May 22, 2017
reply
Follow
share this
hope it helps....
0
0
by
Manu FG
commented
May 22, 2017
reply
Follow
share this
Really appreciate your effort Akash. One doubt though.
So actually increment is taking place first then the deferencing right?. As it is post increment it actually works the way we want to. So it would have been completely different had it been a pre increment operator like *++s right?
0
0
by
A_i_$_h
commented
Jun 18, 2017
reply
Follow
share this
dereferencing first and then incrementing
incase of preincrement, increment and then dereference
try executing this simple code to understand the working of pre and post
#include<stdio.h>
int main()
{
int n=10;
printf("%d",++n);
printf("%d",n++);
}
0
0
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
1
vote
1
vote
the value of *t++ is the character that t pointed to before t was incremented;the postfir ++ doesnt change t untill after this character has been fetched....
referce dennis m ritchie last para...go through that..
soumya singh
answered
May 23, 2017
by
soumya singh
comment
Follow
share this
0 Comments
Please
log in
or
register
to add a comment.
← Previous
Next →
← Previous in category
Next in category →
Related questions
0
votes
0
votes
1
answer
1
Nitesh Choudhary
asked
in
Programming in C
Jun 6, 2017
858
views
5.2 Pointers and Function Arguments book->Dennis M.Ritchie 2nd ed.
"Pointer arguments enable a function to access and change objects in the function that called it. As an example, consider a function getint that performs free-format input conversion by breaking a stream of characters into integer ... can any one explain i didn't get it . this is a portion Chapter 5 - Pointers and Arrays
Nitesh Choudhary
asked
in
Programming in C
Jun 6, 2017
by
Nitesh Choudhary
858
views
programming-in-c
pointers
3
votes
3
votes
0
answers
2
nishitshah
asked
in
Programming in C
Jan 26, 2018
649
views
Ace Test Series: Programming - Pointers And Character
Answer given is option C. How ? I gather that the character pointer will point to the first byte of the integer whose value is 255. But after that what should be the solution ?
nishitshah
asked
in
Programming in C
Jan 26, 2018
by
nishitshah
649
views
programming-in-c
pointers
ace-test-series
1
vote
1
vote
1
answer
3
BIPLAB DAS
asked
in
Programming in C
Jul 18, 2017
852
views
Dennis Ritchie book 'THE C PROGRAMMING LANGUAGE' EXERCISE-1-8,PAGE-20,CHAPTER-1.
#include<stdio.h> main() { int c,nb,nt,nn; nb=0; nt=0; nn=0; while((c=getchar())!=EOF) if(c==' ') ++nb; else if(c=='\t') ++nt; else if(c=='\n') ++ ... t%d\t%d",nb,nt,nn); } the program does not show output for corresponding string input in Dev C++.Can anyone please answer this?
BIPLAB DAS
asked
in
Programming in C
Jul 18, 2017
by
BIPLAB DAS
852
views
programming-in-c
0
votes
0
votes
0
answers
4
Akhilesh Singla
asked
in
Programming in C
Mar 17, 2018
608
views
Should I go through C Programming Language(2nd Edition) by Dennis Ritchie or not
Hi. I gave GATE 2018 by dropping the year and I was able to solve most of the GATE questions on programming. Before GATE I didn't have any interest in programming. But now I like it! Although, I ... worth my time or should I instead solve more questions like ones given in Test Your C Skills by Yashwent Kanetkar?
Akhilesh Singla
asked
in
Programming in C
Mar 17, 2018
by
Akhilesh Singla
608
views
programming-in-c
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