Do not look at it. Do not think about it. Do not even think about thinking about it.
If you did look at it though, do not take your eyes off it. Make sure you firmly think about it before, during and after blinking. And if you start getting tired, have someone else take over. May god have mercy on your soul.
//THE COMPARATOR FUNCTION.
int comp(const void * aa, const void * bb)
{ struct strdef *left = *(struct strdef**)aa;
struct strdef *right = *(struct strdef**)bb;
printf("sheet checked &f &f \n\n",&(left->sheet),&(right->sheet));
if (&left->sheet==&right->sheet)
{ if ((struct strdef *)&left->ant==(struct strdef *)&right->ant)
{ if (&left->pigs==&right->pigs)
{ if (&left->industry==&right->industry)
{ if (&left->pin==&right->pin)
{ if (&left->quartz==&right->quartz)
{ if (&left->condition==&right->condition)
{ if (&left->jump==&right->jump)
{ if (&left->doctor==&right->doctor)
{ if (&left->throne==&right->throne)
{ if (&left->crack==&right->crack)
{ if (&left->plantation==&right->plantation)
{ printf("will now check wash\n\n");
printf("\n%p\t%c\n\n",&left->wash,&right->wash);
//This right here is the problem
if (strcmp(&left->wash,&right->wash)==0)
{ if (&left->cry==&right->cry)
{ if (&left->lake==&right->lake)
{ if (&left->scarf==&right->scarf)
{ if (&left->trade==&right->trade)
return 0;
else if (&left->trade < &right->trade) //trade[cut off]
return 1;
else
return -1;
}
else if (&left->scarf < &right->scarf) //scarf -- [cut off]
return 1;
else
You might think so, but, at least with our bot, it doesn't. We use ocr.space's API, which is one of the best in the world, but when trying to do code it comes out with stuff like this... my theory is that it's probably trained on non-monospace data and that throws it off for things like code. I've found the same problem with all other OCRs I've tried for personal use. The biggest thing is indentation, but skipping characters or whole lines or misinterpreting one character as another are also common issues.
I agree here I have attempted to use ocr to extract code from code printed out and it regularly messes up small lines like unary ifs or even drops or inserts underscores or other letters
Really a nice one, wonder if something similar is not in my history. a common problem, the deep compare, in last projects I used reflection in java or a same thing but for C#.
Is there something for C to create a generic iterateble compare like reflection? It's decades since I used it and now I am curious ...
However, it's usually somewhat bad form to use it from a software engineering perspective. Once had to review a new game engine's (in 2014, no less!) source code working at a billion dollar corp, and everything they had was void pointers where they could have easily used typed pointers. I'm very sure this undid a lot of the performance gains they hoped to get, because using void pointers really tells the compiler you care about a memory address only, and to make no assumptions about what is there.
The only time I've ever really seen void pointers used is when overloading the new and delete operators.
It seems that for a generic comparator function like the image in the OP was going for, a template function should have been used, no? (I'm trying to remember some c++ that I've become way too rusty with)
I think your issue is more your lack of understanding of pointers than pointers themselves. Not understanding the arrow pointer and thinking it makes the code harder to read kinda precludes you from making a judgement over all pointers. Like you didn't even recognise this as C over C++.
Don't get me wrong pointers are really hard to wrap your head around initially but try using them before saying any code that uses them becomes illegible. You can get by never learning a language that needs them but I wouldn't decry them before you do.
Anyone can say they have any job fella, you don't need to get flustered in a Reddit comment section. It's obvious from your comments you don't know what you're talking about, nothing at all to do with your intelligence just to do with your knowledge on this subject matter.
If you write code in C for a living and think it's impossible to write non-spaghetti code with pointers then you don't write good C.
&myval->field (...) is far more ugly than myval.field (...) which is all my comment said. Forcing themselves to use pointers when it's completely unnecessary.
and wrote this is getting a little tiring. I get it, you don't use pointers, you don't know how they work but just stop pretending already.
The dot and arrow operators have the highest precedence of any operator in C, &myval->field is equivalent to &(myval->field) and NOT myval.field.
What you were thinking of is myval->field is equivalent to (&myval)->field, which would have been a weird choice. Again, they're not forcing themselves to use pointers.
They're hard to track which is the reason for RTTI and smart pointers.
Oh deary me fella. So you do use smart pointers and aren't just scared of pointers in general. Again, you're confused. In C++, raw pointers are often a code smell. It's almost always best to be using some form of smart pointer. The issue with the code in the OP is that it is not C++ so you can't judge it for not using C++ features or C++ libraries.
In C you do use raw pointers.
I'm sure you're grand at whatever the day job is but stop coming into badcode threads and talking on languages you don't understand, learn to take an L. Your comments about that guy's python and now your comments about this C are so off-base. No programmer knows everything about every language so stop feeling like you need to. You don't need to pretend you write C for your job and not just C++.
25
u/myblindy Aug 31 '21
Note the scroll bar, it's all like that -.-
11
u/fosf0r Sep 01 '21
It's a virus. It made you post it. It made someone transcribe it. It will make many re-post it here. It will make us suffer.
83
u/Lataero Aug 31 '21
The "this right here is the problem" comment should be just above the method declaration
44
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Aug 31 '21
Image Transcription: Text & Code
My attempt at using pointers:
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
12
u/SnoogySocks Aug 31 '21
Problems I found wrong with the code:
Feel free to add more if I missed any
5
u/ahollister Aug 31 '21
Will now check wash...
3
u/thanatica Sep 01 '21
This person might as well fall onto their knees, and howl into the night sky "PLEASE GIVE ME MEMORY ACCESS VIOLATIONS, OH MIGHTY GOD OF C"
Or alternatively get a bad mark for this piece of way-too-clever homework, simply for shouting THE COMPARATOR FUNCTION in their code.
3
u/abrams666 Sep 01 '21
Really a nice one, wonder if something similar is not in my history. a common problem, the deep compare, in last projects I used reflection in java or a same thing but for C#.
Is there something for C to create a generic iterateble compare like reflection? It's decades since I used it and now I am curious ...
2
u/the_monkey_of_lies Sep 01 '21
THE COMPARATOR FUNCTION
1
u/super_mister_mstie Aug 31 '21
Wow
1
u/arzen221 Sep 01 '21
All hail the great comparator function
1
u/andresx85 Sep 01 '21
For god sake
1
u/nati9931 Sep 01 '21
Pointers are one of the best parts of the C fanily' Please, learn to use them correctly! It isn't as hard as you think at first
1
u/supersharp Sep 01 '21
Sorry, I only really know C++; what the hell is a void pointer?!
1
u/BarryFruitman Sep 02 '21
pig, throne, plantation, scarf... WTF do these objects represent???
1
u/BarryFruitman Sep 02 '21
Stick to Javascript
1
u/DKMR Sep 04 '21
All I could see in there is the word cry. And cry I did...
0
u/[deleted] Sep 01 '21
[deleted] — view deleted comment
0
u/[deleted] Aug 31 '21
[deleted] — view deleted comment