Thread: Allegro Textprintf_ex array

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    12

    Allegro Textprintf_ex array

    Hey folks,

    I've got another Problem.

    I have to give out an array with textprintf_ex but it doesn't work like I wrote it:

    Code:
    textprintf_ex(screen,font,table_x,table_y,makecol(255,255,255), -1,"%s", table[c][l]);

  2. #2
    Registered User antred's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    257
    People here aren't psychic (well, I shouldn't speak for others but I know I'm not ). "It doesn't work." is a tad generic. Please clarify.

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    12
    Haha, sorry, I'm in a hurry and forgetting some esential things ;D

    The compiling works fine and the programm starts.
    But if the function starts and comes to the "textprintf_ex" it quits and I get an error report from Windows.
    If I comment it out it works.

  4. #4
    Registered User antred's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    257
    Then I suspect that table[c][l] contains garbage rather than a proper null-terminated string. Can you post a minimal example program? It's impossible to say where you're going wrong if all you show us is that one line.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    My guess is table[c][l] is a char, not a string.
    So perhaps print it as %c rather than %s.

    Interpreting a single char as a char pointer (which %s will do) will almost certainly blow up.

    You know, when windows halts a process due to memory violations, it usually prints the address.
    If that address is 0x000000nn, then yes, you're taking a char as an address.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Jun 2012
    Posts
    12
    Yeey, that was it
    Thank you so much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro...?
    By Mokkan in forum Game Programming
    Replies: 4
    Last Post: 01-16-2004, 07:52 PM
  2. Allegro Help.
    By tetraflare in forum Game Programming
    Replies: 1
    Last Post: 12-07-2002, 11:35 PM
  3. Allegro
    By Bert in forum Game Programming
    Replies: 8
    Last Post: 10-15-2002, 08:49 PM
  4. Allegro
    By drdroid in forum C++ Programming
    Replies: 0
    Last Post: 02-27-2002, 02:52 PM
  5. Var - Char array in Allegro ?
    By SublicK in forum C++ Programming
    Replies: 2
    Last Post: 10-12-2001, 08:44 PM