473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to convert char * to CString?

Hi everybody,I am new and I am doing a project for Pocket PC using evc 3

here is my question, I have declared a STRUCT to the Binary file
struct config{
int rtuid;
int netid;
char * wlstationcode;
char * rfstationcode;
char * stationname;
char * lastdate;
char * lasttime;
}line;
I have successfully write 255 records inside the binary file,now i want to read from that binary file and show it on a TextBox in my application,So I need to have all my variables to put in a CString.

FILE * info;
CString out;
for(coun=1;coun<=255;coun++){

info=fopen("\\My Documents\\rtu\\config.ini","rb");
outconfig.Format(_T("%d %d %s %s %s %s %s \r\n")
,line.rtuid,line.netid,line.rfstationcode,line.wls tationcode,line.stationname,line.lastdate,line.las ttime);
}
fclose(info);
GetDlgItem(IDC_CONFIGFILE) -> SetWindowText(out);

but it when output appear there is wrong data for those which i declared as char * inside the STRUCT.

Thanks in Advance
Sep 18 '07 #1
1 5501
pgafa
1
You cannot read into a pointer which is not pointing to anywhere. You must initialize the pointers with a valid address!


Hi everybody,I am new and I am doing a project for Pocket PC using evc 3

here is my question, I have declared a STRUCT to the Binary file
struct config{
int rtuid;
int netid;
char * wlstationcode;
char * rfstationcode;
char * stationname;
char * lastdate;
char * lasttime;
}line;
I have successfully write 255 records inside the binary file,now i want to read from that binary file and show it on a TextBox in my application,So I need to have all my variables to put in a CString.

FILE * info;
CString out;
for(coun=1;coun<=255;coun++){

info=fopen("\\My Documents\\rtu\\config.ini","rb");
outconfig.Format(_T("%d %d %s %s %s %s %s \r\n")
,line.rtuid,line.netid,line.rfstationcode,line.wls tationcode,line.stationname,line.lastdate,line.las ttime);
}
fclose(info);
GetDlgItem(IDC_CONFIGFILE) -> SetWindowText(out);

but it when output appear there is wrong data for those which i declared as char * inside the STRUCT.

Thanks in Advance
Sep 18 '07 #2

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

Similar topics

6
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 =...
2
by: jt | last post by:
Looking for an example how to convert and CString to an ASCII character string. Any examples on how to do this? Thank you, jt
3
by: Morten Overgaard | last post by:
Hi How do I convert a managed System::String to a CString. I need to handle unicode characters ( Japan and Chinese ) as well as "normal" ANSI characters. I have tried the following char* p...
15
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
4
by: sklett | last post by:
I have dealt with converting managed C++ String* to PCSTR using the Marshal class, but now I need to get managed C++ String* converted to MFC CString. I can't seem to figure out how this is...
7
by: EOS | last post by:
Hi, I would like to ask on how to convert array of bytes, Byte into String? I tried StringIwant = System.Convert.ToString(byteData); but it actually return "System.Byte" rather than convert...
5
by: Neo | last post by:
how convert CString to char *? regards, Mohammad Omer Nasir
3
by: codercoder | last post by:
It is a C++ questions: How to Convert unsigned char to CString and char *; and backward as well?
4
by: krishp | last post by:
Hi, I need to convert raw data recieved from a device through C#.Net socket to BMP format. For some reason the image conversion is not happening proparly and I can see only blur image . ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.