Does vaprintf support %s??

This is a discussion on Does vaprintf support %s?? within the C++ Programming forums, part of the General Programming Boards category; When I use vaprintf in a text print function that has the multiple argument thing, and I use %s in ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    162

    Does vaprintf support %s??

    When I use vaprintf in a text print function that has the multiple argument thing, and I use %s in the input text, with it's respective char string, it doesn't work(the print function doesn't display it). I have had this problem before, but now I actually care. So does vaprintf support %s or do I have to use something else? Thanks alot!

    Code:
    Print(GLint x, GLint y, const char *string, ...)	// Where The Printing Happens
    {    
    char		text[256];
    	va_list		ap;										// Pointer To List Of Arguments
    
    	if (string == NULL)									// If There's No Text
    		return;											// Do Nothing
    
    	va_start(ap, string);									// Parses The String For Variables
    	    vsprintf(text, string, ap);						// And Converts Symbols To Actual Numbers
    	va_end(ap);	
    
    //There's more to this I just edited it out
    }
    
    //And I call it like:
    
    Print(100,100, "console: %s", console[CurrentLine].string);

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Yes it does

    > Print(100,100, "console: %s", console[CurrentLine].string);
    Does
    - console[CurrentLine].string have a \0
    - is the combined result < 256 chars

    Perhaps

    char text[256];

    Should be bigger for your use

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  3. Dev-cpp - compiler options
    By tretton in forum C Programming
    Replies: 7
    Last Post: 01-06-2006, 05:20 PM
  4. Replies: 1
    Last Post: 09-25-2003, 08:25 AM

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