<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[eigenes pseudo printf() fehler bei long double und algemeine fragen dazu]]></title><description><![CDATA[<p>Hi !</p>
<p>Ich hab mich neulich ein bisschen mit Ansi-Escape-Sequenzen auseinander gesetzt.<br />
Dabei fiel mir auf das es zu fehlern in zusammenhang mit einem lineFeed kommt (noch nicht ausgearbeitet)..<br />
Das wiederum hat mich dazu veranlasst mal so ne eigene art printf()zu bauen, wobei ich trotzdem printf anstatt std::cout benutze. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>In meinem code gibt es einen fehler wenn ich ein long double parameter abfragen will, ansonsten funktioniert er ganz gut.</p>
<p>Jetzt meine fragen:<br />
a)gibt es eine möglichkeit vorbelegte parameter vor dem format string zu platzieren z.B so:</p>
<pre><code>int _printf(unsigned char _fgColor=0, unsigned char _bgColor=0, const char *strIn, ...)
</code></pre>
<p>soweit ich weis geht das nur mit folgeparametern aber fragen kostet ja nix <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>b)hat irgendwer ne schönere Idee, als diese mega lange fallentscheidung in _printf()</p>
<p>c)was mache ich beim long double falsch (vermutete stelle kommentiert) ?</p>
<p>d) was sind eigendlich die rückgabewerte von printf (oder ist das ne void ?) mal in der referenz nachschauen....</p>
<p>Ich poste hier mal den ganzen code, auch wenn er nen bissl lang geworden ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;iostream&gt;
#include &quot;time.h&quot;

#ifdef WIN32
  #define WINDOWS
#elif WIN64
  #define WINDOWS
#elif _WIN32
  #define WINDOWS
#elif linux
  #define LINUX
#elif _linux_
  #define LINUX
#elif __APPLE__
	#define MAC
#endif

//Farb Konstanten Linux/Unix/BSD für terminals die &quot;ansi escape sequenzen&quot; unterstützen
#define normal	0x00
#define black   0x1E
#define red 		0x1F
#define green   0x20
#define yellow  0x21
#define blue    0x22
#define magenta 0x23
#define cyan    0x24
#define white   0x25

//nicht schön aber selten :P
int bgColor(unsigned char _bgColor)
{
  #ifdef WINDOWS
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi;  	
		GetConsoleScreenBufferInfo(hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,((csbi.wAttributes &amp; 0xFF0F) | (_bgColor &lt;&lt; 4)));
  #endif
	#ifdef LINUX
		if(_bgColor!=0)
		{
			return printf(&quot;\033[%im&quot;,(_bgColor+10));
		}else
		{
			return printf(&quot;\033[%im&quot;,0);
		} 
  #endif
	#ifdef MAC
    #warning console.text.bgColor() not implemented for Mac yet 
    return 0;
	#endif
}
//nicht schön aber selten :P
int fgColor(unsigned char _fgColor)
{
  #ifdef WINDOWS  
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi; 
  	GetConsoleScreenBufferInfo( hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,(csbi.wAttributes &amp; 0xFFF0) | _fgColor);   
  #endif
	#ifdef LINUX
		return printf(&quot;\033[%im&quot;,_fgColor); 
  #endif
	#ifdef MAC
    #warning console.text.fgColor() not implemented for Mac yet 
    return 0;
	#endif
}

int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *strIn, ...)
{
	bool flgParams=0;
	char modifier=0;
	char buffer[2048]={};
	char *ptrStrIn=(char*)strIn;
	char *ptrBuffer=&amp;buffer[0];

	bgColor(_bgColor); 
	fgColor(_fgColor);

	va_list params;
	va_start(params,strIn);

	while(*ptrStrIn != 0)
	{
		*ptrBuffer++=*ptrStrIn;
		//Format untersuchen (modifier wird mit untersucht. [genauigkeit / breite / anzahl vor u. nachkommastellen werden printf überlassen]):
		if(flgParams==1)
		{
			switch(*ptrStrIn)
			{
				case 'h':	 case 'l': case 'L':
					modifier=*ptrBuffer;
				break;

				case 's':
					printf(buffer,va_arg(params, const char*));
					ptrBuffer=&amp;buffer[0];
					while(*ptrBuffer!=0)*ptrBuffer++=0;
					ptrBuffer=&amp;buffer[0];
					flgParams=0;
					modifier=0;
				break;

				case 'c':
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, const char*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'h':
							printf(buffer,va_arg(params, short int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'l':
							printf(buffer,va_arg(params, long int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
					}
				break;

				case 'p':
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, void*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'h':
							printf(buffer,va_arg(params, short int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'l':
							printf(buffer,va_arg(params, long int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
					}
				break;

				case 'n':
					printf(buffer,va_arg(params, int*));
					ptrBuffer=&amp;buffer[0];
					while(*ptrBuffer!=0)*ptrBuffer++=0;
					ptrBuffer=&amp;buffer[0];
					flgParams=0;
					modifier=0;
				break;

				case 'i': case 'd':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'h':
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'l':
							printf(buffer,va_arg(params, long int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;

				case 'u': case 'o': case 'x': case 'X':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, unsigned int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'h':
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'l':
							printf(buffer,va_arg(params, unsigned int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;

				case 'f': case 'e': case 'E': case 'g': case 'G':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, double));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'L':
							printf(buffer,va_arg(params, long double)); //Der blöde long double error ?!?
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;
			}		
		}
		//Wenn Formatierungszeichen gefunden, Format überprüfungs flag setzen 
		if(*ptrStrIn++=='%')
		{
			if(flgParams==1)
			{
				flgParams=0;
			}else
			{
				flgParams=1;
			}
		}
	}
	printf(&quot;%s&quot;,buffer);
	va_end(params);
	bgColor(normal);	
	fgColor(normal);
	return 0;
}

int main(int argc, char* argv[])
{
	char chr=123;
	int integer=123;
	unsigned int uint=123;
	short int sinteger=123;
	long int linteger=123;
	double dbl=123.321;
	long double ldbl=123.321;

	const char *cchar=&quot;HalloWelt!&quot;;
	char *addy=(char*)cchar;
	void *paddy=&amp;cchar;

	_printf(cyan,normal,&quot;Variablen:\n&quot;);

	printf(&quot;%s\n&quot;,cchar);
	_printf(red,normal,&quot;%s\n&quot;,cchar);

	printf(&quot;CHAR %c\n&quot;,'#');
	_printf(red,normal,&quot;CHAR %c\n&quot;,'#');

	printf(&quot;INT %i\n&quot;,integer);
	_printf(red,normal,&quot;INT %i\n&quot;,integer);		

	printf(&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);
	_printf(red,normal,&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);	

	printf(&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);
	_printf(red,normal,&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);

	printf(&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);
	_printf(red,normal,&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);

	printf(&quot;sINT %hi\n&quot;,sinteger);
	_printf(red,normal,&quot;sINT %hi\n&quot;,sinteger);	

	printf(&quot;lINT %li\n&quot;,linteger);
	_printf(red,normal,&quot;lINT %hi\n&quot;,linteger);	

	_printf(cyan,normal,&quot;Speicher Addressen:\n&quot;);

	printf(&quot;ADDY: %p\n&quot;,&amp;addy);
	_printf(red,normal,&quot;ADDY: %p\n&quot;,paddy);	

	printf(&quot;pADDY: %p\n&quot;,&amp;addy);
	_printf(red,normal,&quot;pADDY: %p\n&quot;,paddy);	

	return 0;
}
</code></pre>
<p>Für jedliche hilfe / hinweise würde ich mich sehr, sehr freuen...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312793/eigenes-pseudo-printf-fehler-bei-long-double-und-algemeine-fragen-dazu</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 12:53:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312793.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Jan 2013 14:16:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:16:16 GMT]]></title><description><![CDATA[<p>Hi !</p>
<p>Ich hab mich neulich ein bisschen mit Ansi-Escape-Sequenzen auseinander gesetzt.<br />
Dabei fiel mir auf das es zu fehlern in zusammenhang mit einem lineFeed kommt (noch nicht ausgearbeitet)..<br />
Das wiederum hat mich dazu veranlasst mal so ne eigene art printf()zu bauen, wobei ich trotzdem printf anstatt std::cout benutze. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>In meinem code gibt es einen fehler wenn ich ein long double parameter abfragen will, ansonsten funktioniert er ganz gut.</p>
<p>Jetzt meine fragen:<br />
a)gibt es eine möglichkeit vorbelegte parameter vor dem format string zu platzieren z.B so:</p>
<pre><code>int _printf(unsigned char _fgColor=0, unsigned char _bgColor=0, const char *strIn, ...)
</code></pre>
<p>soweit ich weis geht das nur mit folgeparametern aber fragen kostet ja nix <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>b)hat irgendwer ne schönere Idee, als diese mega lange fallentscheidung in _printf()</p>
<p>c)was mache ich beim long double falsch (vermutete stelle kommentiert) ?</p>
<p>d) was sind eigendlich die rückgabewerte von printf (oder ist das ne void ?) mal in der referenz nachschauen....</p>
<p>Ich poste hier mal den ganzen code, auch wenn er nen bissl lang geworden ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;iostream&gt;
#include &quot;time.h&quot;

#ifdef WIN32
  #define WINDOWS
#elif WIN64
  #define WINDOWS
#elif _WIN32
  #define WINDOWS
#elif linux
  #define LINUX
#elif _linux_
  #define LINUX
#elif __APPLE__
	#define MAC
#endif

//Farb Konstanten Linux/Unix/BSD für terminals die &quot;ansi escape sequenzen&quot; unterstützen
#define normal	0x00
#define black   0x1E
#define red 		0x1F
#define green   0x20
#define yellow  0x21
#define blue    0x22
#define magenta 0x23
#define cyan    0x24
#define white   0x25

//nicht schön aber selten :P
int bgColor(unsigned char _bgColor)
{
  #ifdef WINDOWS
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi;  	
		GetConsoleScreenBufferInfo(hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,((csbi.wAttributes &amp; 0xFF0F) | (_bgColor &lt;&lt; 4)));
  #endif
	#ifdef LINUX
		if(_bgColor!=0)
		{
			return printf(&quot;\033[%im&quot;,(_bgColor+10));
		}else
		{
			return printf(&quot;\033[%im&quot;,0);
		} 
  #endif
	#ifdef MAC
    #warning console.text.bgColor() not implemented for Mac yet 
    return 0;
	#endif
}
//nicht schön aber selten :P
int fgColor(unsigned char _fgColor)
{
  #ifdef WINDOWS  
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi; 
  	GetConsoleScreenBufferInfo( hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,(csbi.wAttributes &amp; 0xFFF0) | _fgColor);   
  #endif
	#ifdef LINUX
		return printf(&quot;\033[%im&quot;,_fgColor); 
  #endif
	#ifdef MAC
    #warning console.text.fgColor() not implemented for Mac yet 
    return 0;
	#endif
}

int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *strIn, ...)
{
	bool flgParams=0;
	char modifier=0;
	char buffer[2048]={};
	char *ptrStrIn=(char*)strIn;
	char *ptrBuffer=&amp;buffer[0];

	bgColor(_bgColor); 
	fgColor(_fgColor);

	va_list params;
	va_start(params,strIn);

	while(*ptrStrIn != 0)
	{
		*ptrBuffer++=*ptrStrIn;
		//Format untersuchen (modifier wird mit untersucht. [genauigkeit / breite / anzahl vor u. nachkommastellen werden printf überlassen]):
		if(flgParams==1)
		{
			switch(*ptrStrIn)
			{
				case 'h':	 case 'l': case 'L':
					modifier=*ptrBuffer;
				break;

				case 's':
					printf(buffer,va_arg(params, const char*));
					ptrBuffer=&amp;buffer[0];
					while(*ptrBuffer!=0)*ptrBuffer++=0;
					ptrBuffer=&amp;buffer[0];
					flgParams=0;
					modifier=0;
				break;

				case 'c':
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, const char*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'h':
							printf(buffer,va_arg(params, short int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'l':
							printf(buffer,va_arg(params, long int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
					}
				break;

				case 'p':
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, void*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'h':
							printf(buffer,va_arg(params, short int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
						case 'l':
							printf(buffer,va_arg(params, long int*));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;	
						break;
					}
				break;

				case 'n':
					printf(buffer,va_arg(params, int*));
					ptrBuffer=&amp;buffer[0];
					while(*ptrBuffer!=0)*ptrBuffer++=0;
					ptrBuffer=&amp;buffer[0];
					flgParams=0;
					modifier=0;
				break;

				case 'i': case 'd':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'h':
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'l':
							printf(buffer,va_arg(params, long int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;

				case 'u': case 'o': case 'x': case 'X':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, unsigned int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'h':
							printf(buffer,va_arg(params, int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'l':
							printf(buffer,va_arg(params, unsigned int));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;

				case 'f': case 'e': case 'E': case 'g': case 'G':	
					switch(modifier)
					{
						case 0:
							printf(buffer,va_arg(params, double));
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
						case 'L':
							printf(buffer,va_arg(params, long double)); //Der blöde long double error ?!?
							ptrBuffer=&amp;buffer[0];
							while(*ptrBuffer!=0)*ptrBuffer++=0;
							ptrBuffer=&amp;buffer[0];
							flgParams=0;
							modifier=0;
						break;
					}
				break;
			}		
		}
		//Wenn Formatierungszeichen gefunden, Format überprüfungs flag setzen 
		if(*ptrStrIn++=='%')
		{
			if(flgParams==1)
			{
				flgParams=0;
			}else
			{
				flgParams=1;
			}
		}
	}
	printf(&quot;%s&quot;,buffer);
	va_end(params);
	bgColor(normal);	
	fgColor(normal);
	return 0;
}

int main(int argc, char* argv[])
{
	char chr=123;
	int integer=123;
	unsigned int uint=123;
	short int sinteger=123;
	long int linteger=123;
	double dbl=123.321;
	long double ldbl=123.321;

	const char *cchar=&quot;HalloWelt!&quot;;
	char *addy=(char*)cchar;
	void *paddy=&amp;cchar;

	_printf(cyan,normal,&quot;Variablen:\n&quot;);

	printf(&quot;%s\n&quot;,cchar);
	_printf(red,normal,&quot;%s\n&quot;,cchar);

	printf(&quot;CHAR %c\n&quot;,'#');
	_printf(red,normal,&quot;CHAR %c\n&quot;,'#');

	printf(&quot;INT %i\n&quot;,integer);
	_printf(red,normal,&quot;INT %i\n&quot;,integer);		

	printf(&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);
	_printf(red,normal,&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);	

	printf(&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);
	_printf(red,normal,&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);

	printf(&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);
	_printf(red,normal,&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);

	printf(&quot;sINT %hi\n&quot;,sinteger);
	_printf(red,normal,&quot;sINT %hi\n&quot;,sinteger);	

	printf(&quot;lINT %li\n&quot;,linteger);
	_printf(red,normal,&quot;lINT %hi\n&quot;,linteger);	

	_printf(cyan,normal,&quot;Speicher Addressen:\n&quot;);

	printf(&quot;ADDY: %p\n&quot;,&amp;addy);
	_printf(red,normal,&quot;ADDY: %p\n&quot;,paddy);	

	printf(&quot;pADDY: %p\n&quot;,&amp;addy);
	_printf(red,normal,&quot;pADDY: %p\n&quot;,paddy);	

	return 0;
}
</code></pre>
<p>Für jedliche hilfe / hinweise würde ich mich sehr, sehr freuen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289561</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:16:16 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:20:59 GMT]]></title><description><![CDATA[<p>long double und printf machen unter Windows häufiger Probleme...<br />
Verwende einfach std::cout oder caste.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289565</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:20:59 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:32:57 GMT]]></title><description><![CDATA[<p>Da sind an sich noch jede Menge Fehler drin, die mein Compiler/Debugger automatisch aufzählen:</p>
<pre><code>test.c: In function ‘int bgColor(unsigned char)’:
test.c:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
test.c: At global scope:
test.c:35:5: warning: unused parameter ‘_bgColor’ [-Wunused-parameter]
 int bgColor(unsigned char _bgColor)
     ^
test.c: In function ‘int fgColor(unsigned char)’:
test.c:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
test.c: At global scope:
test.c:58:5: warning: unused parameter ‘_fgColor’ [-Wunused-parameter]
 int fgColor(unsigned char _fgColor)
     ^
test.c: In function ‘int main(int, char**)’:
test.c:283:10: warning: unused variable ‘chr’ [-Wunused-variable]
     char chr=123;
          ^
test.c: At global scope:
test.c:281:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char* argv[])
     ^
test.c:281:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
 int main(int argc, char* argv[])
     ^
</code></pre>
<pre><code>==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A66D: __printf_fp (printf_fp.c:359)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073== 
==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A50D: __printf_fp (printf_fp.c:447)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073== 
==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A531: __printf_fp (printf_fp.c:454)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073==
</code></pre>
<p>Mach erst einmal, dass dein Programm technisch korrekt arbeitet, dann kann man sich um Logikfehler kümmern.</p>
<p>Zu deinem Vorhaben insgesamt: Du sagst, dass du dieses Monstrum geschrieben hast, da du Probleme mit line feeds hast. Vielleicht wäre ein guter Ansatz gewesen, hier nach diesem Problem zu fragen, anstatt sich selber ein printf zu programmieren.</p>
<p>P.S.: Falls du es nicht bemerkst: Die uninitialisierten Werte treten bei deinem long double _printf-Aufrunf auf, aber Zeile 243 ist deine double-Behandlung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289570</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289570</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:32:57 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:28:30 GMT]]></title><description><![CDATA[<p>du mußt mal prüfen, ob bei deinem Compiler das long double 64 oder 80 Bit hat. wenn es 80 Bit hat, muß du prüfen, mit welchem Alignment es auf dem Stack abgelegt wird (z.B. eine Funktion mit 2 long double Parametern deklarieren und in der Funktion die Adressen der Parameter ausgeben)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289571</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:29:00 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>long double und printf machen unter Windows häufiger Probleme...<br />
Verwende einfach std::cout oder caste.</p>
</blockquote>
<p>hehe gut, ich arbeite unter linux also zumindest momentan, da es mir ja um die escape sequenzen geht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>naja gut aber ist natürlich die frage ob da jetzt 8 oder 4 bytes allokiert werden... aber gut dann versuch ich es mal mit casten ansonsten währe ein cout auch nicht dumm, danke für den tipp !</p>
<p>Mfg Benny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289572</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:30:49 GMT]]></title><description><![CDATA[<p>dd++ schrieb:</p>
<blockquote>
<p>du mußt mal prüfen, ob bei deinem Compiler das long double 64 oder 80 Bit hat. wenn es 80 Bit hat, muß du prüfen, mit welchem Alignment es auf dem Stack abgelegt wird (z.B. eine Funktion mit 2 long double Parametern deklarieren und in der Funktion die Adressen der Parameter ausgeben)</p>
</blockquote>
<p>gute idee, danke !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289573</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:32:19 GMT]]></title><description><![CDATA[<p>wieso nicht einfach vprintf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289575</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:32:19 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:33:07 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Da sind an sich noch jede Menge Fehler drin, die mein Compiler/Debugger automatisch aufzählen:</p>
<pre><code>test.c: In function ‘int bgColor(unsigned char)’:
test.c:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
test.c: At global scope:
test.c:35:5: warning: unused parameter ‘_bgColor’ [-Wunused-parameter]
 int bgColor(unsigned char _bgColor)
     ^
test.c: In function ‘int fgColor(unsigned char)’:
test.c:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
test.c: At global scope:
test.c:58:5: warning: unused parameter ‘_fgColor’ [-Wunused-parameter]
 int fgColor(unsigned char _fgColor)
     ^
test.c: In function ‘int main(int, char**)’:
test.c:283:10: warning: unused variable ‘chr’ [-Wunused-variable]
     char chr=123;
          ^
test.c: At global scope:
test.c:281:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char* argv[])
     ^
test.c:281:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
 int main(int argc, char* argv[])
     ^
</code></pre>
<pre><code>==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A66D: __printf_fp (printf_fp.c:359)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073== 
==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A50D: __printf_fp (printf_fp.c:447)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073== 
==13073== Conditional jump or move depends on uninitialised value(s)
==13073==    at 0x561A531: __printf_fp (printf_fp.c:454)
==13073==    by 0x561696A: vfprintf (vfprintf.c:1622)
==13073==    by 0x561F9C9: printf (printf.c:35)
==13073==    by 0x40146B: _printf(unsigned char, unsigned char, char const*, ...) (test.c:243)
==13073==    by 0x4017D2: main (test.c:310)
==13073==
</code></pre>
<p>Mach erst einmal, dass dein Programm technisch korrekt arbeitet, dann kann man sich um Logikfehler kümmern.</p>
<p>Zu deinem Vorhaben insgesamt: Du sagst, dass du dieses Monstrum geschrieben hast, da du Probleme mit line feeds hast. Vielleicht wäre ein guter Ansatz gewesen, hier nach diesem Problem zu fragen, anstatt sich selber ein printf zu programmieren.</p>
</blockquote>
<p>ich weis ja nicht welchen compiler du verwendest... die compieler direktieven sind glaub ich gcc speziefisch... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289576</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:33:07 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:37:01 GMT]]></title><description><![CDATA[<p>McMorf schrieb:</p>
<blockquote>
<p>ich weis ja nicht welchen compiler du verwendest... die compieler direktieven sind glaub ich gcc speziefisch... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>GCC (wie du siehst, sind deine Makros wohl falsch), aber die Fehler gelten in jedem anderen nicht-unterstüzten Compiler auch. Du musst aufpassen, dass in deinen define-Orgien einen sinnvollen default-Fall oder wenigstens einen Fehler produzieren, wenn nichts passt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289579</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:37:01 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:37:20 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>wieso nicht einfach vprintf?</p>
</blockquote>
<p>int vprintf ( const char * format, va_list arg );</p>
<p>ich find irgendwie das währe leicht verwirrend oder ?!?</p>
<p>also du meinst doch einfach die vorbelegten funktions parameter oder ?!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289580</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:37:20 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:39:10 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>McMorf schrieb:</p>
<blockquote>
<p>ich weis ja nicht welchen compiler du verwendest... die compieler direktieven sind glaub ich gcc speziefisch... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>GCC (wie du siehst, sind deine Makros wohl falsch), aber die Fehler gelten in jedem anderen nicht-unterstüzten Compiler auch. Du musst aufpassen, dass in deinen define-Orgien einen sinnvollen default-Fall oder wenigstens einen Fehler produzieren, wenn nichts passt.</p>
</blockquote>
<p>da hast du scheinbar nicht unrecht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
werd in zukunft besser drauf achten, hab aber jetzt mal nicht mit sowas gerechnet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289582</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:39:10 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:43:48 GMT]]></title><description><![CDATA[<pre><code>fugitivus@fugitivus:~/workspace$ g++ -o main main.cpp time.c -Wall
main.cpp: In Funktion »int main(int, char**)«:
main.cpp:283:7: Warnung: Variable »chr« wird nicht verwendet [-Wunused-variable]
</code></pre>
<pre><code>fugitivus@fugitivus:~/workspace$ ./main
Variablen:
HalloWelt!
HalloWelt!
CHAR #
CHAR #
INT 123
INT 123
uINT 123 &gt; 173 &gt; 7b &gt; 7B
uINT 123 &gt; 173 &gt; 7b &gt; 7B
LONG DBL 123.321 &gt; 123.321000 &gt; 1.233210E+02 
LONG DBL -0 &gt; -0.000000 &gt; -0.000000E+00 
DBL 123.321 &gt; 1.233210E+02 &gt; 1.23e+02
DBL 123.321 &gt; 1.233210E+02 &gt; 1.23e+02
sINT 123
sINT 123
lINT 123
lINT 123
Speicher Addressen:
ADDY: 0x7fff741731c0
ADDY: 0x7fff741731c0
pADDY: 0x7fff741731b8
pADDY: 0x7fff741731b8
fugitivus@fugitivus:~/workspace$
</code></pre>
<p>vlt liegt es ja auch an der fehlenden time.c (keine ahnung) ?!?</p>
<p>Mfg Benny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289583</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:43:48 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:49:37 GMT]]></title><description><![CDATA[<p>McMorf schrieb:</p>
<blockquote>
<p>camper schrieb:</p>
<blockquote>
<p>wieso nicht einfach vprintf?</p>
</blockquote>
<p>int vprintf ( const char * format, va_list arg );</p>
<p>ich find irgendwie das währe leicht verwirrend oder ?!?</p>
<p>also du meinst doch einfach die vorbelegten funktions parameter oder ?!?</p>
</blockquote>
<p>Ich meine</p>
<pre><code class="language-cpp">int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *strIn, ...)
{
    bgColor(_bgColor);
    fgColor(_fgColor);

    va_list params;
    va_start(params,strIn);

    int result = vprintf(strIn, params);
    va_end(params);
    bgColor(normal);   
    fgColor(normal);
    return result;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2289589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289589</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:49:37 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:52:54 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>McMorf schrieb:</p>
<blockquote>
<p>camper schrieb:</p>
<blockquote>
<p>wieso nicht einfach vprintf?</p>
</blockquote>
<p>int vprintf ( const char * format, va_list arg );</p>
<p>ich find irgendwie das währe leicht verwirrend oder ?!?</p>
<p>also du meinst doch einfach die vorbelegten funktions parameter oder ?!?</p>
</blockquote>
<p>Ich meine</p>
<pre><code class="language-cpp">int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *strIn, ...)
{
    bgColor(_bgColor);
    fgColor(_fgColor);
 
    va_list params;
    va_start(params,strIn);
 
    int result = vprintf(strIn, params);
    va_end(params);
    bgColor(normal);   
    fgColor(normal);
    return result;
}
</code></pre>
</blockquote>
<p>*haaaaaaaaare außreiß* <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> also eleganter geht nimmer, wenn man eh kein std::cout verwenden wollte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> mein gott... naja immerhin, ist es nicht an der logik gescheitert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Super Herzlichen Dank für all eure Bemühungen !!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289590</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:52:54 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 14:58:58 GMT]]></title><description><![CDATA[<p>mist...<br />
geht nicht, wenn ich jetzt ein '\n' im format string habe, tritt mein problem ja wieder auf, es einfach raus schneiden geht nicht, weil dann ja wieder funktionalität verloren geht...</p>
<p>mfg benny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289594</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 14:58:58 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 15:05:47 GMT]]></title><description><![CDATA[<p>Beschreib doch einfach mal dein Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289596</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 14 Jan 2013 15:05:47 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 15:18:08 GMT]]></title><description><![CDATA[<p>zu meinem problem :<br />
<a href="http://www.c-plusplus.net/forum/312345" rel="nofollow">http://www.c-plusplus.net/forum/312345</a></p>
<p>noch ein neuer ansatz:</p>
<pre><code>int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *strIn, ...)
{
    bgColor(_bgColor);
    fgColor(_fgColor);

    va_list params;
    va_start(params,strIn);

    int result = vprintf(strIn, params);
    va_end(params);
    bgColor(normal);  
    fgColor(normal);
    return result;
}
</code></pre>
<p>vlt einfach den formatstring auf '\n' untersuchen, an der stelle abschneiden, nur den teil vor dem '\n' an vprintf() übergeben(mit kompletter parameter liste) ,dann farbe zurück setzen, dann '\n' an std übergeben,und dann beim nächsten teilstring weiter machen, solange bis kein '\n' mehr zu finden ist..... ich kann doch eigendlich die ganze parameter liste jedes mal mit übergeben oder ?!? &lt;-- mist ich hab immer noch nicht nach den rückgabe werten von printf o. vprintf geguckt...</p>
<p>uff was nen kauderwälsch, ich hoffe ihr versteht mich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Mfg Benny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289601</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Mon, 14 Jan 2013 15:18:08 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 15:36:37 GMT]]></title><description><![CDATA[<p>Versuche es mal mit <a href="http://www.cplusplus.com/reference/cstdio/vsprintf/" rel="nofollow">vsprintf</a>.<br />
Die Ausgabe ist in einem string und dann gibst du die zwei teile mit puts() oder printf aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289607</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 14 Jan 2013 15:36:37 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 15:42:38 GMT]]></title><description><![CDATA[<p>Ich nehme an die Funktionen <code>bgColor()</code> und <code>fgColor()</code> werden auch nur diverse Steuercodes ausgeben...?<br />
Falls das der Fall ist, kannst du ja alle <code>\n</code> im Format-String ersetzen mit einem String der erst die original Farbe setzt, dann das <code>\n</code> und dann wieder die gewünschte Farbe setzt.</p>
<p>Also quasi aus &quot; <code>Trallala: %d\nBlub: %d</code> &quot; würde dann &quot; <code>Trallala: %d{set-bg-color-sequence}{set-fg-color-sequence}\n{set-bg-color-sequence}{set-fg-color-sequence}Blub: %d</code> &quot;.</p>
<p>Da sich dadurch nichts an der Reihenfolge und Art der Formatierungszeichen ändert, kannst du den so modifizierten String dann 1:1 an <code>vprintf</code> übergeben.</p>
<p>Was dein Vorhaben mit dem Zerstückeln des Format-Strings angeht... nein, das geht nicht so einfach. <code>printf/vprintf</code> kann ja z.B. beim 2. Teilstück nicht wissen wie viele/welche Formatierungszeichen im ersten Teilstück enthalten waren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289608</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 14 Jan 2013 15:42:38 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 16:24:26 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Versuche es mal mit <a href="http://www.cplusplus.com/reference/cstdio/vsprintf/" rel="nofollow">vsprintf</a>.<br />
Die Ausgabe ist in einem string und dann gibst du die zwei teile mit puts() oder printf aus.</p>
</blockquote>
<p>nimm lieber <a href="http://linux.die.net/man/3/vasprintf" rel="nofollow">http://linux.die.net/man/3/vasprintf</a>, da hast du nicht das Problem mit dem Bufferoverflow</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289620</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Mon, 14 Jan 2013 16:24:26 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 16:49:48 GMT]]></title><description><![CDATA[<p>dd++ schrieb:</p>
<blockquote>
<p>nimm lieber <a href="http://linux.die.net/man/3/vasprintf" rel="nofollow">http://linux.die.net/man/3/vasprintf</a>, da hast du nicht das Problem mit dem Bufferoverflow</p>
</blockquote>
<p>&lt;a href= schrieb:</p>
<blockquote>
<p>man: vasprintf(3)&quot;&gt;These functions are GNU extensions, not in C or POSIX. They are also available under *BSD. The FreeBSD implementation sets strp to NULL on error.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2289624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289624</guid><dc:creator><![CDATA[quoter]]></dc:creator><pubDate>Mon, 14 Jan 2013 16:49:48 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Mon, 14 Jan 2013 16:51:55 GMT]]></title><description><![CDATA[<p>McMorf arbeitet mit g++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289625</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Mon, 14 Jan 2013 16:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Tue, 15 Jan 2013 06:48:42 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Ich nehme an die Funktionen <code>bgColor()</code> und <code>fgColor()</code> werden auch nur diverse Steuercodes ausgeben...?<br />
Falls das der Fall ist, kannst du ja alle <code>\n</code> im Format-String ersetzen mit einem String der erst die original Farbe setzt, dann das <code>\n</code> und dann wieder die gewünschte Farbe setzt.</p>
<p>Also quasi aus &quot; <code>Trallala: %d\nBlub: %d</code> &quot; würde dann &quot; <code>Trallala: %d{set-bg-color-sequence}{set-fg-color-sequence}\n{set-bg-color-sequence}{set-fg-color-sequence}Blub: %d</code> &quot;.</p>
<p>Da sich dadurch nichts an der Reihenfolge und Art der Formatierungszeichen ändert, kannst du den so modifizierten String dann 1:1 an <code>vprintf</code> übergeben.</p>
<p>Was dein Vorhaben mit dem Zerstückeln des Format-Strings angeht... nein, das geht nicht so einfach. <code>printf/vprintf</code> kann ja z.B. beim 2. Teilstück nicht wissen wie viele/welche Formatierungszeichen im ersten Teilstück enthalten waren.</p>
</blockquote>
<p>Ja, manchmal sieht man den wald vor lauter bäumen nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
aber darauf währ ich gez nie gekommen, wobei das ja der einfachste ansatz ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2289751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2289751</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Tue, 15 Jan 2013 06:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Wed, 16 Jan 2013 11:50:40 GMT]]></title><description><![CDATA[<p>habs dann mal weiter ausgearbeitet, schon viel schöner das ganze....<br />
ok, das mit den compiler anweisungen muss ich mir dann mal angucken, aber immo benutz ich ja nur gcc/g++....</p>
<p>hier mal der code:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;iostream&gt;

#ifdef WIN32
  #define WINDOWS
#elif WIN64
  #define WINDOWS
#elif _WIN32
  #define WINDOWS
#elif linux
  #define LINUX
#elif _linux_
  #define LINUX
#elif __APPLE__
	#define MAC
#endif

//Farb Konstanten Linux/Unix/BSD für terminals die &quot;ansi escape sequenzen&quot; unterstützen
#define normal	0x00
#define black   0x1E
#define red 		0x1F
#define green   0x20
#define yellow  0x21
#define blue    0x22
#define magenta 0x23
#define cyan    0x24
#define white   0x25

//nicht schön aber selten :P
int bgColor(unsigned char _bgColor)
{
  #ifdef WINDOWS
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi;  	
		GetConsoleScreenBufferInfo(hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,((csbi.wAttributes &amp; 0xFF0F) | (_bgColor &lt;&lt; 4)));
  #endif
	#ifdef LINUX
		if(_bgColor!=0)
		{
			return printf(&quot;\033[%im&quot;,(_bgColor+10));
		}else
		{
			return printf(&quot;\033[%im&quot;,0);
		} 
  #endif
	#ifdef MAC
    #warning console.text.bgColor() not implemented for Mac yet 
    return 0;
	#endif
}
//nicht schön aber selten :P
int fgColor(unsigned char _fgColor)
{
  #ifdef WINDOWS  
		hwnd=GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi; 
  	GetConsoleScreenBufferInfo( hwnd, &amp;csbi );
  	return SetConsoleTextAttribute(hwnd,(csbi.wAttributes &amp; 0xFFF0) | _fgColor);   
  #endif
	#ifdef LINUX
		return printf(&quot;\033[%im&quot;,_fgColor); 
  #endif
	#ifdef MAC
    #warning console.text.fgColor() not implemented for Mac yet 
    return 0;
	#endif
}

int mkForeColor(char *colorString ,unsigned char color)
{
	char buffer[10]={};
	char *ptrBuffer=&amp;buffer[0];
	sprintf(buffer,&quot;\033[%im&quot;,color);
	while(*ptrBuffer!=0)*colorString++=*ptrBuffer++;
	return strlen(buffer);
}
int mkBackColor(char *colorString ,unsigned char color)
{
	char buffer[10]={};
	char *ptrBuffer=&amp;buffer[0];
	sprintf(buffer,&quot;\033[%im&quot;,(color+10));
	while(*ptrBuffer!=0)*colorString++=*ptrBuffer++;
	return strlen(buffer);
}

int _printf(unsigned char _fgColor, unsigned char _bgColor, const char *format, ...)
{
	char color[10]={};
	char buffer[4096]={};
	char *ptrBuff=&amp;buffer[0];
	char *ptrColor=&amp;color[0];

	#ifdef LINUX
		while(*format!=0)
		{
			if(*format!='\n')
			{
				*ptrBuff++=*format++;
			}else
			{
				mkBackColor(color,normal);
				while(*ptrColor!=0)*ptrBuff++=*ptrColor++;
				*ptrBuff++='\n';		
				ptrColor=&amp;color[0];	
				mkBackColor(color,_bgColor);
				while(*ptrColor!=0)*ptrBuff++=*ptrColor++;
				ptrColor=&amp;color[0];	
				format++;
			}
		}
	#endif

  bgColor(_bgColor);
  fgColor(_fgColor);

  va_list params;
  va_start(params,format);
  int result = vprintf(buffer, params);
  va_end(params);

  bgColor(normal);  
  fgColor(normal);
  return result;
}

int main(int argc, char* argv[])
{
	char chr=123;
	int integer=123;
	unsigned int uint=123;
	short int sinteger=123;
	long int linteger=123;
	double dbl=123.321;
	long double ldbl=123.321;

	char *cchar=(char*)&quot;HalloWelt!&quot;;
	char *addy=cchar;
	void *paddy=&amp;cchar;

	_printf(cyan,normal,&quot;Variablen:\n&quot;);

	printf(&quot;%s\n&quot;,cchar);
	_printf(red,normal,&quot;%s\n&quot;,cchar);

	printf(&quot;CHAR %c\n&quot;,'#');
	_printf(red,normal,&quot;CHAR %c\n&quot;,'#');

	printf(&quot;INT %i\n&quot;,integer);
	_printf(red,normal,&quot;INT %i\n&quot;,integer);		

	printf(&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);
	_printf(red,normal,&quot;uINT %u &gt; %o &gt; %x &gt; %X\n&quot;,uint,uint,uint,uint);	

	printf(&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);
	_printf(red,normal,&quot;LONG DBL %LG &gt; %Lf &gt; %LE \n&quot;,ldbl,ldbl,ldbl);

	printf(&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);
	_printf(red,normal,&quot;DBL %.3f &gt; %E &gt; %.2e\n&quot;,dbl,dbl,dbl);

	printf(&quot;sINT %hi\n&quot;,sinteger);
	_printf(red,normal,&quot;sINT %hi\n&quot;,sinteger);	

	printf(&quot;lINT %li\n&quot;,linteger);
	_printf(red,normal,&quot;lINT %hi\n&quot;,linteger);	

	_printf(cyan,normal,&quot;Speicher Addressen:\n&quot;);

	printf(&quot;ADDY: %p\n&quot;,&amp;addy);
	_printf(red,normal,&quot;ADDY: %p\n&quot;,&amp;addy);	

	printf(&quot;pADDY: %p\n&quot;,paddy);
	_printf(red,normal,&quot;pADDY: %p\n&quot;,paddy);	

	return 0;
}
</code></pre>
<p>Herzlichen dank für die ganzen rückmeldungen !<br />
Ihr habt mir sehr geholfen !<br />
Mfg Benny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2290219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2290219</guid><dc:creator><![CDATA[McMorf]]></dc:creator><pubDate>Wed, 16 Jan 2013 11:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to eigenes pseudo printf() fehler bei long double und algemeine fragen dazu on Wed, 16 Jan 2013 13:06:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// ...

int main()
{
    char* fmt = malloc(64*1024);
    memser(fmt, &quot;A&quot;, 64*1024);
    fmt[1024*1024 - 5] = 'a';
    fmt[1024*1024 - 4] = 'h';
    fmt[1024*1024 - 3] = '!';
    fmt[1024*1024 - 2] = '\n';
    fmt[1024*1024 - 1] = 0;
    _printf(black, red, fmt);
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2290244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2290244</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 16 Jan 2013 13:06:41 GMT</pubDate></item></channel></rss>