<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>printf not working for %s const char</title>
<description> I have this problem when I try to print a const char * using printf nothing outputs on the television screen. If a print a constant it appear fine but if I use a %s nothing is outputed. what am I doing wrong? 

my C code looks like this;
engine_console()
Object3D_LoadModel( &quot;model/sspaceship01.obj&quot;, &quot;model/sspaceship01.png&quot;, 2 );

and the function I use to print to the screen looks like; [codepad.org]</description><link>http://forum.wiibrew.org/read.php?11,67245,67245#msg-67245</link><lastBuildDate>Mon, 20 May 2013 10:02:44 +0200</lastBuildDate>
<generator>Phorum 5.2.7</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67379#msg-67379</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67379#msg-67379</link><description><![CDATA[ I was working on some Lua stuff over the weekend and I noticed that whenever I got a crash screen I would see that the data that printf() is out putting about the debug string. More than likely something is wrong with my console video code or a GRRLIB setting is causing it not to output. Either way at least I know now that its not the printf(). :)]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Mon, 25 Jul 2011 18:50:23 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67278#msg-67278</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67278#msg-67278</link><description><![CDATA[ Tueidj has said what I was thinking all along, as I final test (if this does not work maybe delete \devkitPro\libogc downloading a fresh copy - as I feel is this does not work then how many other things may go bad too)<br /><br />Take the example template.c found in...<br />devkitPro\examples\wii\template\source & add this code<br /><pre class="bbcode">
void MyPrintf(char* pText)
{
	printf("Message is %s",pText);
}

// Call it just before start of the while loop

MyPrintf("Testing123");</pre><br />p.s my fist post was poo - you can use strings directly]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Fri, 15 Jul 2011 19:20:21 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67277#msg-67277</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67277#msg-67277</link><description><![CDATA[ You need to reduce your code to the smallest possible complete program that still reproduces the problem. It's obviously caused by something you're not showing since simple test code works fine.<br /><br />Possibly something is turning on buffered output for stdout, try "fflush(stdout)" after the printf calls.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Fri, 15 Jul 2011 18:48:53 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67275#msg-67275</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67275#msg-67275</link><description><![CDATA[ Tried setting a range[255], hmmmm, still doesn't work. I even tried searching snesgx and grrlib source and they don't seem to use it for %s either. hmm...I guess I'll have to skip leave this for some other time. Thanx for your help Titmouse.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Fri, 15 Jul 2011 14:48:40 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67269#msg-67269</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67269#msg-67269</link><description><![CDATA[ I know that it the string is there, because the file load that I do after works perfectly, I just want to print what I'm loading at the moment on the screen. Its not crucial, mostly for debugging the lua scripts. I have 2 more things that I am going to try this evening before I give up on it all together.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 23:42:32 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67267#msg-67267</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67267#msg-67267</link><description><![CDATA[ Just thinking it’s not point 4 - that happens for me as the consoles callback is stops.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 21:41:55 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67266#msg-67266</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67266#msg-67266</link><description><![CDATA[ These might help tracking down this problem.... (maybe some kind of display problem - but feels like its something else not here!)<br /><br />(1) Direct the output to file (SD card), see if it looks ok from there. (I find using ‘WiiXplorer’ is a nice way to view things, I use it for everything including copying files from the PC onto the SD card to test before a release.) <strong class="bbcode">see code</strong><br />(2) Use Dolphin (wii emulator) to view your printf’s – they come up in log view, this is very useful.<br />(3) Calling VIDEO_Flush, think it refreshes the nextFb which console uses (you are).<br />(4) Not sure, maybe call printf on the correct framebuffer, I don't get printf to display at exit unless a toggle to the first buffer - the console is normaly initialised at start-up pointing at first frame buffer.<br /><br /><pre class="bbcode">
// Found some old code of mine on my backup drive, nasty hard coded numbers so look out.
// TracePrintf("My message is: %d %s", 16386, "is a number") ; 
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>  

TracePrintf ( char* Format, ... )
{
	va_list	ArgList;
	char	Str[512];
	FILE*	file;
	static int	FirstTime = 1;

	if ( FirstTime )
		file = fopen ( "trace.log", "wt" );
	else
		file = fopen ( "trace.log", "at" );
	if ( file == NULL )
		return;
	FirstTime = 0;

	va_start ( ArgList, Format );
	_vbprintf ( Str, sizeof(Str), Format, ArgList );
	va_end ( ArgList );

	fprintf ( file, "Message: %s(%d): %s\n", DebugFile, DebugLine, Str );
	fflush ( file );

	fclose ( file );
}</pre>]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 21:36:31 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67264#msg-67264</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67264#msg-67264</link><description><![CDATA[ Tried that too, doesn't work. seems to be something specific with the wii because I can't find anybody have any problem with it on the internet. latest: [<a rel="nofollow" href="http://codepad.org/WgYHfArI">codepad.org</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 15:46:11 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67262#msg-67262</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67262#msg-67262</link><description><![CDATA[ How odd, can you post the latest code example. Looks like I've overlooked something.<br />Also, with printf if needed you can just print a string no need for %s, but what you are saying should still work.<br /><br /><pre class="bbcode">
char *MystringPointer = "Test123";
printf( MystringPointer );
printf( "message is %s", MystringPointer );</pre><br />As a test try this code after your console_init, it should work fine.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 09:31:49 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67259#msg-67259</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67259#msg-67259</link><description><![CDATA[ Nope, still doesn't printf the line. I declared a const char variable and it still doesn't work. Once the I put the %s into the format string it doesn't print anything.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Thu, 14 Jul 2011 01:53:30 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67249#msg-67249</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67249#msg-67249</link><description><![CDATA[ OMG that looks annoying. Going to try it later and see if that solves the problem.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Wed, 13 Jul 2011 20:04:55 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67248#msg-67248</guid>
<title>Re: printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67248#msg-67248</link><description><![CDATA[ Looking at<br /><pre class="bbcode">
Object3D_LoadModel(const char *fn, const char * fn2, int p )</pre><br />You need use a pointer(s) when passing the parametets<br /><br />char Text1[] = "model/sspaceship01.obj"<br />char Text2[] = "model/sspaceship01.png",<br /><br /><pre class="bbcode">
Object3D_LoadModel( Text1, Text2, 2 );
// or another way to do the same thing ... Object3D_LoadModel( &Text1[0], &Text2[0], 2 );</pre>]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Wed, 13 Jul 2011 19:24:46 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,67245,67245#msg-67245</guid>
<title>printf not working for %s const char</title><link>http://forum.wiibrew.org/read.php?11,67245,67245#msg-67245</link><description><![CDATA[ I have this problem when I try to print a const char * using printf nothing outputs on the television screen. If a print a constant it appear fine but if I use a %s nothing is outputed. what am I doing wrong?<br /><br />my C code looks like this;<br /><pre class="bbcode">
engine_console()
Object3D_LoadModel( "model/sspaceship01.obj", "model/sspaceship01.png", 2 );</pre><br />and the function I use to print to the screen looks like; [<a rel="nofollow" href="http://codepad.org/FMEIuMWo">codepad.org</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Wed, 13 Jul 2011 17:37:04 +0200</pubDate></item>
</channel>
</rss>