473,657 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do CString to char * convertion ???

6 New Member
Hy!
The problem, is that I tried everything I could to convert. The following examples are already useless:


//Example 1:
CString text;
char *ch_text = new char[text.GetLength( )+1];
strcpy(ch_text, text);


//Example 2:
CString text;
char *ch_text = text.GetBuffer( );
///some code////
text.ReleaseBuf fer();


//Example 3:
CString text;
const char *ch_text = (LPTSTR)(LPCTST R)text;


So, if you have any other ideas, please tell me!
Thanks!
Dec 12 '06 #1
1 3346
maximbu
4 New Member
Hy!
The problem, is that I tried everything I could to convert. The following examples are already useless:


//Example 1:
CString text;
char *ch_text = new char[text.GetLength( )+1];
strcpy(ch_text, text);


//Example 2:
CString text;
char *ch_text = text.GetBuffer( );
///some code////
text.ReleaseBuf fer();


//Example 3:
CString text;
const char *ch_text = (LPTSTR)(LPCTST R)text;


So, if you have any other ideas, please tell me!
Thanks!
heya,
i'm not sure but try
/////////////////////////////////////////////////////////
CString text;
char *ch_text = tect.c_string() ;
strcpy(ch_text, text);
Dec 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
24519
by: Markus Hämmerli | last post by:
I ' ll tra to convert a Cstring to char* without success. I working in a Unicode enabled environment this is working in Unicode CString source = _T("TestString"); TCHAR *szSource = source.GetBuffer(0 ); but i need a char* and so this is not working CString source = _T("TestString");
8
2304
by: Oskar | last post by:
Hi. I`m new in cpp and i have a litlle problem. i have a CString from Edit Box (eg."aaa bbb ccc 7327373 d feaf 323 dvjiv 234") and i want to put the data (space separated) into an array.It shuld be somethign like this. array1="aaa"; array1="bbb"; .... array1="234";
5
14069
by: Tim Wong | last post by:
All: I am trying to convert a CString value to an unsigned char array. I found some code online that will allow me to compile, but when I try to print out...i get a whole mess. /*Begin Code*/ CString day("01"); unsigned char testDay;
2
3279
by: Javier | last post by:
Hi All I'm in a nightmare trying to do a simple c++ program... I want to read a file that will have strings in a vector. The path where is the file is in a ini file. I did:
3
9134
by: nsyforce | last post by:
What is the correct way to convert a const char* to a CString? I'm somewhat of a newbie and have tried several ways. While they all convert ok, I'm using a profiler that shows a memory leak for every option. Here's what I have tried: const char* test; test = getMyChar(); //CString myCString((LPCTSTR)test); //CString myCString(test); CString myCString = new CString(test);
4
10490
by: Susan Rice | last post by:
I'm new to using CString. Why won't the following compile? I'm using Microsoft Visual C++ 6.0 Line 37 which it complains about is the function: 37 CString ConvertFile(char *szFileName) I tried throwing in a bunch of #includes but didn't help. Here's the compiler errors: Compiling...
8
2583
by: Alexandros H. Halatsis | last post by:
Let's say I have a cstring: char str = "Hello world"; and I have a needle: char n = "wo"; I find that the needle starts at the 5+1 position of the string. How am I going to copy the characters up to this point, using the <cstringheader? -- Using <string(c++ string) it is possible in two ways: 1) for (int counter = 0; i < str.find(n); i++) tmp += str;
6
3572
by: Thomas.li | last post by:
Hi, I want to convert CString to LPBYTE like LPBYTE lpByte = (BYTE*)(LPCTSTR)cstring; is it very dangerous to do that?
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.