Like Tree1Likes
  • 1 Post By Salem

Allegro Textprintf_ex array

This is a discussion on Allegro Textprintf_ex array within the C++ Programming forums, part of the General Programming Boards category; Hey folks, I've got another Problem. I have to give out an array with textprintf_ex but it doesn't work like ...

  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
    251
    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
    251
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    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.
    antred likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 06:52 PM
  2. Allegro Help.
    By tetraflare in forum Game Programming
    Replies: 1
    Last Post: 12-07-2002, 10: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, 01:52 PM
  5. Var - Char array in Allegro ?
    By SublicK in forum C++ Programming
    Replies: 2
    Last Post: 10-12-2001, 08:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21