<?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[c++ Code crasht cmd-box - aber ohne nützlichen fehler]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>Ich bin neu auf diesen Forum und Anfänger mit c++, ich habe ein Programm verfasst, doch wenn ich es ausführe dann crasht es meine cmdbox und ich verstehe nicht warum.</p>
<p>Wäre um hilfe sehr Dankbar, hier ist der Sourcecode:</p>
<p>MAC_Toolbar.cpp:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;atlstr.h&gt;
#include &lt;Windows.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;
using namespace std;

#include &quot;MAC_Variables.h&quot;
#include &quot;MAC_inifuncs.h&quot;

int _tmain(int argc, _TCHAR* argv[])
{
	cout &lt;&lt; &quot;nText: &quot; &lt;&lt; nText &lt;&lt; &quot;\n&quot;;
	nText = &quot;Test\n&quot;;
	cout &lt;&lt; &quot;nText: &quot; &lt;&lt; nText;

	string iTestIniRead=&quot;&quot;; // (LPCWSTR retval, LPCWSTR ifilename, LPCWSTR isection, LPCWSTR ikey, LPCWSTR idefault, int isize = 256)
	//iTestIniRead = iniRead(L&quot;int&quot;, L&quot;test.ini&quot;, L&quot;test&quot;, L&quot;key&quot;, 0);

	cout &lt;&lt; &quot;iniRead int: &quot; &lt;&lt; iTestIniRead &lt;&lt; &quot;\n&quot;;

	iTestIniRead = iniRead(L&quot;string&quot;, L&quot;test.ini&quot;, L&quot;test&quot;, L&quot;key1&quot;, 0);

	cout &lt;&lt; &quot;iniRead str: &quot; &lt;&lt; iTestIniRead &lt;&lt; &quot;\n&quot;;

	system(&quot;pause&gt;nul&quot;);

	return 0;
}
</code></pre>
<p>MAC_Variables.h</p>
<pre><code>#ifdef MAC_Rebuild
	#define EXTERN
#else
	#define EXTERN extern
#endif

EXTERN std::string nText=&quot;Hello World&quot;;// = file(;
</code></pre>
<p>und<br />
MAC_inifuncs.h</p>
<pre><code>string iniRead(LPCWSTR retval, LPCWSTR ifilename, LPCWSTR isection, LPCWSTR ikey, LPCWSTR idefault, int isize = 256) {

	LPWSTR itemp=0;

	if (lstrcmp(retval, L&quot;int&quot;) ) {

		std::string itemp2 = CW2A(idefault);	// Convert LPCSWSTR to String
		int idefaultini;						// int idefault
		istringstream(itemp2) &gt;&gt; idefaultini;	// Convert String to int

		int itemp;
		itemp = GetPrivateProfileInt(isection, ikey, idefaultini, ifilename);		// int
		std::string iret = std::to_string(itemp);
		return iret;

	} 

	else if (lstrcmp(retval, L&quot;bool&quot;)) {

		DWORD iret;
		iret = GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// boolean
		//std::to_string(iretstring)
		//std::string test = CW2A(itemp);
		std::string test = std::to_string(iret);
		return test;

	}	

	else if (lstrcmp(retval, L&quot;float&quot;)) {

		GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// float
		//std::to_string(iretstring)
		std::string iret = CW2A(itemp);
		return iret;		// float

	}

	else if (lstrcmp(retval, L&quot;string&quot;)) {

		GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// float
		//std::to_string(iretstring)
		std::string iret = CW2A(itemp);
		return iret;		// float

	} 

	else {
		return &quot;Error - Please choose Data type.&quot;;
	}

}
</code></pre>
<p>Der crash kommt immer wenn ich die iniRead function ausführe.</p>
<p>Danke für die Hilfe.</p>
<p>Grüße, Busti.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/330814/c-code-crasht-cmd-box-aber-ohne-nützlichen-fehler</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 18:23:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/330814.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Jan 2015 16:45:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to c++ Code crasht cmd-box - aber ohne nützlichen fehler on Mon, 26 Jan 2015 16:45:07 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>Ich bin neu auf diesen Forum und Anfänger mit c++, ich habe ein Programm verfasst, doch wenn ich es ausführe dann crasht es meine cmdbox und ich verstehe nicht warum.</p>
<p>Wäre um hilfe sehr Dankbar, hier ist der Sourcecode:</p>
<p>MAC_Toolbar.cpp:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;atlstr.h&gt;
#include &lt;Windows.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;
using namespace std;

#include &quot;MAC_Variables.h&quot;
#include &quot;MAC_inifuncs.h&quot;

int _tmain(int argc, _TCHAR* argv[])
{
	cout &lt;&lt; &quot;nText: &quot; &lt;&lt; nText &lt;&lt; &quot;\n&quot;;
	nText = &quot;Test\n&quot;;
	cout &lt;&lt; &quot;nText: &quot; &lt;&lt; nText;

	string iTestIniRead=&quot;&quot;; // (LPCWSTR retval, LPCWSTR ifilename, LPCWSTR isection, LPCWSTR ikey, LPCWSTR idefault, int isize = 256)
	//iTestIniRead = iniRead(L&quot;int&quot;, L&quot;test.ini&quot;, L&quot;test&quot;, L&quot;key&quot;, 0);

	cout &lt;&lt; &quot;iniRead int: &quot; &lt;&lt; iTestIniRead &lt;&lt; &quot;\n&quot;;

	iTestIniRead = iniRead(L&quot;string&quot;, L&quot;test.ini&quot;, L&quot;test&quot;, L&quot;key1&quot;, 0);

	cout &lt;&lt; &quot;iniRead str: &quot; &lt;&lt; iTestIniRead &lt;&lt; &quot;\n&quot;;

	system(&quot;pause&gt;nul&quot;);

	return 0;
}
</code></pre>
<p>MAC_Variables.h</p>
<pre><code>#ifdef MAC_Rebuild
	#define EXTERN
#else
	#define EXTERN extern
#endif

EXTERN std::string nText=&quot;Hello World&quot;;// = file(;
</code></pre>
<p>und<br />
MAC_inifuncs.h</p>
<pre><code>string iniRead(LPCWSTR retval, LPCWSTR ifilename, LPCWSTR isection, LPCWSTR ikey, LPCWSTR idefault, int isize = 256) {

	LPWSTR itemp=0;

	if (lstrcmp(retval, L&quot;int&quot;) ) {

		std::string itemp2 = CW2A(idefault);	// Convert LPCSWSTR to String
		int idefaultini;						// int idefault
		istringstream(itemp2) &gt;&gt; idefaultini;	// Convert String to int

		int itemp;
		itemp = GetPrivateProfileInt(isection, ikey, idefaultini, ifilename);		// int
		std::string iret = std::to_string(itemp);
		return iret;

	} 

	else if (lstrcmp(retval, L&quot;bool&quot;)) {

		DWORD iret;
		iret = GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// boolean
		//std::to_string(iretstring)
		//std::string test = CW2A(itemp);
		std::string test = std::to_string(iret);
		return test;

	}	

	else if (lstrcmp(retval, L&quot;float&quot;)) {

		GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// float
		//std::to_string(iretstring)
		std::string iret = CW2A(itemp);
		return iret;		// float

	}

	else if (lstrcmp(retval, L&quot;string&quot;)) {

		GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);		// float
		//std::to_string(iretstring)
		std::string iret = CW2A(itemp);
		return iret;		// float

	} 

	else {
		return &quot;Error - Please choose Data type.&quot;;
	}

}
</code></pre>
<p>Der crash kommt immer wenn ich die iniRead function ausführe.</p>
<p>Danke für die Hilfe.</p>
<p>Grüße, Busti.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439872</guid><dc:creator><![CDATA[Busti]]></dc:creator><pubDate>Mon, 26 Jan 2015 16:45:07 GMT</pubDate></item><item><title><![CDATA[Reply to c++ Code crasht cmd-box - aber ohne nützlichen fehler on Mon, 26 Jan 2015 17:11:54 GMT]]></title><description><![CDATA[<p>Ich habe nur mal kurz überflogen aber laut msdn muss lpReturnedString ein Pointer sein der auf einen Buffer zeigt.<br />
Aber das ist bei dir einfach nur ein Pointer ohne Wert und du tust so als würde er auf einen 256er Buffer zeigen.</p>
<pre><code>//Aufruf

 LPWSTR itemp=0; 
 GetPrivateProfileString(isection, ikey, idefault, itemp, isize, ifilename);     // float
</code></pre>
<p>Laut MSDN:</p>
<p>DWORD WINAPI GetPrivateProfileString(<br />
_In_ LPCTSTR lpAppName,<br />
_In_ LPCTSTR lpKeyName,<br />
_In_ LPCTSTR lpDefault,<br />
_Out_ LPTSTR lpReturnedString,<br />
_In_ DWORD nSize,<br />
_In_ LPCTSTR lpFileName<br />
);</p>
<p><strong>ReturnedString [out]</strong><br />
A pointer to the buffer that receives the retrieved string.</p>
<p><strong>nSize [in]</strong><br />
The size of the buffer pointed to by the lpReturnedString parameter, in characters.</p>
<p>P.S.: Ka welche IDE du benutzt, aber in C++ braucht man eine IDE bei der man Breakpoints setzen kann.<br />
Dann koenntest Du Breakpoints setzen und Schritt für Schritt durch die Funktion gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439874</guid><dc:creator><![CDATA[Ruvi]]></dc:creator><pubDate>Mon, 26 Jan 2015 17:11:54 GMT</pubDate></item><item><title><![CDATA[Reply to c++ Code crasht cmd-box - aber ohne nützlichen fehler on Mon, 26 Jan 2015 20:04:44 GMT]]></title><description><![CDATA[<p>gdb funktioniert auch wunderbar aus der Konsole raus, das hat sogar einen TUI-Mode.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439911</guid><dc:creator><![CDATA[NewHope]]></dc:creator><pubDate>Mon, 26 Jan 2015 20:04:44 GMT</pubDate></item></channel></rss>