?
Solved

c output

Posted on 2007-03-26
2
Medium Priority
?
245 Views
Last Modified: 2010-04-15
the output 4 the following code:

main()
{
char *p="ayqm";
char c;
c=++*p++;
printf("%c",c);
}

when i do this i get some windows error q60.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
the answer given by the author is 'b'.can ne1 please explain this?
0
Comment
Question by:shilpi84
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
fridom earned 2000 total points
ID: 18793946
what shoulc ++*p++ do? That code will not work.

The claims of the author are wrong and well it just shows misuse of C
Howerver the idea is that p is dereferences so it yield a
after that p should be advances by one step (but that will surely not work that way)
and after that the dereferences parameter is incremented
that means after 'a' follows 'b'
But that is just the idea and that simply does not work, I doubt that any C compiler will give the "result" the author claims it does.

It's exactly that kind of programming that has given C programign such a bad reputation. Will you win anything with that obfuscation? why not write it simply
c = *p++;
c++;
?
Ah yes and with buffered output you will not see anything printed at all.

This code is just BBB (BadBeyondBelief)

Regards
Friedrich
0
 

Author Comment

by:shilpi84
ID: 18794122
thanks 4 ur guidance:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question