Jump to content
  • Advertisement
Sign in to follow this  
mathware

What is the output?

This topic is 871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I tried to debug the following code "on paper" (without compiler/debugger),but it seems that is not possible because of the pointers.


#include <stdio.h>

#define MAX 10
int main()
{
    char array[MAX][MAX], c = 0;
    int d = 1, x = 0, i, j;
    
    do
        scanf("%s", array[x]);
    while (array[x++][0] != '0');

        float* pf;
        int xx, *pi = (int*)&array[0][7];
        xx = ((*pi) & 0x41000000);
        pf = (float*)&xx;
        printf("%5.2f\n", *pf);
    
    for (c- = --x; c++ & **array; d+=!(c << x > 0)) 
        d<<=1;
        
    d -= c;
    
    for (i = 0; i < x; i == 1 ? printf("%c ", array[i][x >> 1]):i, ++i)
        for (j = 0; j <= x - i; printf("%c", array[i][j++]));
    printf("%x", d);
    
    return 0;
}

//Example input:

programming languages 0


//Output:
 2.00
prolaa 6

Could someone explain this code?

 

Share this post


Link to post
Share on other sites
Advertisement

Why is that not possible?

Draw each variable as a rectangle at the paper, write its value in the rectangle (and for ease of reference, write the name of the variable next to the rectangle).
Pointers are rectangles that have an arrow from inside their rectangle pointing to another rectangle.
 

int i = 10; // Draw a rectangle, write 10 inside, write 'i' next to it.
int *p = &i; // Draw a rectangle, draw an arrow from the center of that rectangle pointing to the 'i' rectangle, write 'p' next to it.

Good luck with your home work!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!