Click here to Skip to main content
14,827,196 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Could someone explain this code:

#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: code project
Output: 2.00
codprr 6

I debugged it with Code Blocks, but didn't understand how it works. What tools for debugging would you suggest?
PIEBALDconsult 1-Mar-15 12:19pm
Better formatting might help.
What for?.. :-)
Please see the comments below.
Richard MacCutchan 1-Mar-15 12:20pm
Impossible to understand. It looks like some 'clever' code that produces some special results.
The question is: does it worth understanding or even reading? I doubt it... :-)
Albert Holguin 1-Mar-15 14:41pm
That's horrible code... you should throw that away and forget you ever saw it.
Best advice so far.
You need to understand: "explaining code" is a waste time and not anything constructive or useful. Write your own code, so you could at least explain the purpose of each piece and ask questions if you have problem with it.

1 solution

I would suggest using gdb debugger to run and trace each variable. Use it to stop at different points.
Else format it nicely with brackets and run in Visual Studio with breakpoints. Watch each variable in each loop.
I wonder why bothering... :-)
Member 11489314 2-Mar-15 3:05am
I had exam assignment, and this type of problem showed up. The code is given and you have to analyze it line by line. If anyone has time to explain this code in shorts I would be very thankful.
I'm not sure your school really teaches students...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900