<?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[CString in fopen ?]]></title><description><![CDATA[<p>Ich bekomme bei</p>
<pre><code class="language-cpp">CFileDialog dlg(FALSE, DEFAULT_BITMAP_FILE_EXTENSION, DEFAULT_BITMAP_FILE_NAME, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, NULL);
	if(dlg.DoModal() == IDOK)
	{
		CString szPathName = dlg.GetPathName();
		//Create a new file for writing
		FILE *pFile = fopen(szPathName, &quot;wb&quot;);
</code></pre>
<p>den Fehler</p>
<blockquote>
<p>'fopen': Konvertierung des Parameters 1 von 'CString' in 'const char *' nicht möglich</p>
</blockquote>
<p>nur liefert mir dlg.GetPathName(); ein CString, aber fopen verlangt ein 'char *'<br />
Wie konvertiere ich das, oder wie umgehe ich dieses Problem ?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/178944/cstring-in-fopen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 17:00:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/178944.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Apr 2007 21:00:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CString in fopen ? on Mon, 16 Apr 2007 21:00:15 GMT]]></title><description><![CDATA[<p>Ich bekomme bei</p>
<pre><code class="language-cpp">CFileDialog dlg(FALSE, DEFAULT_BITMAP_FILE_EXTENSION, DEFAULT_BITMAP_FILE_NAME, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, NULL);
	if(dlg.DoModal() == IDOK)
	{
		CString szPathName = dlg.GetPathName();
		//Create a new file for writing
		FILE *pFile = fopen(szPathName, &quot;wb&quot;);
</code></pre>
<p>den Fehler</p>
<blockquote>
<p>'fopen': Konvertierung des Parameters 1 von 'CString' in 'const char *' nicht möglich</p>
</blockquote>
<p>nur liefert mir dlg.GetPathName(); ein CString, aber fopen verlangt ein 'char *'<br />
Wie konvertiere ich das, oder wie umgehe ich dieses Problem ?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267390</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Mon, 16 Apr 2007 21:00:15 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Mon, 16 Apr 2007 21:55:49 GMT]]></title><description><![CDATA[<p>Also eigentlich sollte das so gehen, wie Du das machst. <em><strong>CString</strong></em> hat einen operator <em><strong>const char</strong></em>*, der so etwas i.d.R. erledigt. Ich habe den Auszug unten einfach bei mir in eine Dialog-Testapplikation reinkopiert, und es geht (VC 6.0). Und <em><strong>fopen</strong></em> will ja einen <em><strong>const char</strong></em>* und keinen ***char ****.</p>
<p>Welche Umgebung, bzw. welchen Compiler benutzt Du?</p>
<p>Gruss, Gio</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267413</guid><dc:creator><![CDATA[Gio]]></dc:creator><pubDate>Mon, 16 Apr 2007 21:55:49 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 06:04:28 GMT]]></title><description><![CDATA[<p>Ich tippe mal spontan auf UNICODE-Probleme (CString hat einen <code>operator LPCTSTR</code> - normal ist das ein char*, unter Unicode hast du dort einen wchar_t*). Da mußt du entweder nachsehen, ob es eine TCHAR-generische Version von fopen() gibt, oder du verwendest T2A(), um den String zu konvertieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267465</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 17 Apr 2007 06:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 06:25:04 GMT]]></title><description><![CDATA[<p>Gio schrieb:</p>
<blockquote>
<p>Welche Umgebung, bzw. welchen Compiler benutzt Du?</p>
</blockquote>
<p>VS 2005 SP1. Es geht auch in einem anderen Projekt (Beispiel aus dem Internet). Nur in meinem eigenen Projekt geht es nicht. Muss ich dazu noch zusätzliche Bibilotheken laden ?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267477</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Tue, 17 Apr 2007 06:25:04 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 06:29:42 GMT]]></title><description><![CDATA[<p>pospiech schrieb:</p>
<blockquote>
<p>Nur in meinem eigenen Projekt geht es nicht. Muss ich dazu noch zusätzliche Bibilotheken laden ?</p>
</blockquote>
<p>CStoll hat dir doch schon gesagt, was du tun musst: Benutz _tfopen oder wandel den String um.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267480</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 17 Apr 2007 06:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 09:45:57 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>oder du verwendest T2A(), um den String zu konvertieren.</p>
</blockquote>
<p>Bei mir ist T2A nicht bekannt. Woher bekomme ich daher diese Funktion um CString umzuwandlen?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267600</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Tue, 17 Apr 2007 09:45:57 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 10:16:34 GMT]]></title><description><![CDATA[<p>Versuch's mal bei den <a href="http://msdn2.microsoft.com/en-us/library/87zae4a3.aspx" rel="nofollow">String Conversion Makros</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267622</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 17 Apr 2007 10:16:34 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Tue, 17 Apr 2007 14:28:55 GMT]]></title><description><![CDATA[<p>Und wofür überhaupt? Setz deinen Zeichensatz entweder auf ANSI oder nimm die verdammte Funktionsform aus tchar.h -.-</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1267790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1267790</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Tue, 17 Apr 2007 14:28:55 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Sun, 22 Apr 2007 18:11:25 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<p>Und wofür überhaupt? Setz deinen Zeichensatz entweder auf ANSI oder nimm die verdammte Funktionsform aus tchar.h -.-</p>
</blockquote>
<p>Ich habe jetzt nach ANSI umgeschaltet und dann funktioniert ein</p>
<pre><code class="language-cpp">FILE *pFile = fopen((LPCTSTR)szPathName, &quot;wb&quot;);
</code></pre>
<p>was du mit tchar.h meinst ist mir aber noch unklar. In der Hilfe habe ich nur den Beitrag <a href="http://msdn2.microsoft.com/de-de/library/c426s321(VS.80).aspx" rel="nofollow">http://msdn2.microsoft.com/de-de/library/c426s321(VS.80).aspx</a> gefunden der mir aber nicht weitergeholfen hat.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271333</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sun, 22 Apr 2007 18:11:25 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Mon, 23 Apr 2007 06:06:02 GMT]]></title><description><![CDATA[<p>tchar.h enthält Makros und Definitionen, die es einem erlaben Projekte so zu schreiben, dass sie sowohl als Unicode als auch als MBCS Projkete funktionieren.<br />
Ganz besonders nett sind die Converter Makros wie CT2A!</p>
<p>CString ist eben ein Typ, der in einem MBCS Projekt char's enthält und in einem Unicode Projekt wchar_t!</p>
<p>BZW: Es gibt auch eine UNICODE Variante von fopen und eine neutrale Variante _tfopen!</p>
<p>Aber das haben andere schon geschrieben, Du solltest es einfach mal beachten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271461</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 23 Apr 2007 06:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to CString in fopen ? on Mon, 23 Apr 2007 14:14:05 GMT]]></title><description><![CDATA[<p>pospiech schrieb:</p>
<blockquote>
<p>Gio schrieb:</p>
<blockquote>
<p>Welche Umgebung, bzw. welchen Compiler benutzt Du?</p>
</blockquote>
<p>VS 2005 SP1. Es geht auch in einem anderen Projekt (Beispiel aus dem Internet). Nur in meinem eigenen Projekt geht es nicht. Muss ich dazu noch zusätzliche Bibilotheken laden ?</p>
<p>Matthias</p>
</blockquote>
<p>Natürlich geht das auch bei eigenen Projekten, wenn man bei der Erzeugung des Projektes mit VS2005 die Verwendung von Unicode abschaltet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271788</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Mon, 23 Apr 2007 14:14:05 GMT</pubDate></item></channel></rss>