Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Text input using allegro 5

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Text input using allegro 5
Neil Roy
Member #2,229
April 2002
avatar

My apologies. But it does need to be stated that modern C is not that way anymore or you could send a false impression to someone.

Both C and C++ have changed quite a bit since the '90s, and for the better.

I always say, use what you are the most comfortable with. Give both a try and see which you prefer.

---
“I love you too.” - last words of Wanda Roy

Scooter
Member #16,799
January 2018

Good morning Edgar:
I got your 'input.c' program to compile. A super program indeed.
It works perfectly! This will help a lot of folks having problems
working with the keyboard. I know it took a great deal of time to put
it together, and for that, I say THANKS!
Something you might want to take a look at: Code:Blocks issues a
Warning on line 19. Evidently it means nothing because the program
runs fine. Here's the code in question:

void AssertHandler(const char* expr , const char* file , int line , const char* func) {
int i = 0;

printf("%s failed in file %s on line %d in function %s\n" , expr , file , line , func);

i /= 0;
return;
}

Neil Roy
Member #2,229
April 2002
avatar

i /= 0; ??? You should get a warning about this one, you're trying to divide by zero?

I don't even see why int i = 0; is in there. It sets i to zero, then later tries to divide it by zero then return. i is not used.

Just remove it entirely.

void AssertHandler(const char* expr , const char* file , int line , const char* func)
{
   printf("%s failed in file %s on line %d in function %s\n" , expr , file , line , func);
}

...that should work just fine. No need for the i variable, the divide by zero or even the return statement as it is a void function.

---
“I love you too.” - last words of Wanda Roy

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Neil, it's intentional. The divide by zero is on purpose, because it allows the debugger to catch the exception. This allows you to get a backtrace when the program fails an ALLEGRO_ASSERT. Otherwise the program exits and you can only see where the assert failed, not the stack when it does.

So keep the divide by zero, it's on purpose.

Neil Roy
Member #2,229
April 2002
avatar

Neil, it's intentional. The divide by zero is on purpose, because it allows the debugger to catch the exception.

Ah, okay, I had a feeling that might have been it. That's an interesting trick.

---
“I love you too.” - last words of Wanda Roy

 1   2   3 


Go to: