Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c output

Posted on 2007-03-26
2
Medium Priority
?
246 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

610 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