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

C#
#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?
Posted
Comments
PIEBALDconsult 1-Mar-15 12:19pm    
Better formatting might help.
Sergey Alexandrovich Kryukov 1-Mar-15 21:55pm    
What for?.. :-)
Please see the comments below.
—SA
Richard MacCutchan 1-Mar-15 12:20pm    
Impossible to understand. It looks like some 'clever' code that produces some special results.
Sergey Alexandrovich Kryukov 1-Mar-15 21:55pm    
The question is: does it worth understanding or even reading? I doubt it... :-)
—SA
Albert Holguin 1-Mar-15 14:41pm    
That's horrible code... you should throw that away and forget you ever saw 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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Mar-15 21:56pm    
I wonder why bothering... :-)
—SA
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.
Sergey Alexandrovich Kryukov 2-Mar-15 8:17am    
I'm not sure your school really teaches students...
—SA

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