Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2006, 10:45 PM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default evc++: splitting string into array using strtok

Hi,

I am using embedded visual C++ 4.0 and I want to use function strtok to split string into array.

my sample code is as below:

----------------------------------------------------------------
void CNEWSERIALNO::OnBInsert()
{
// TODO: Add your control notification handler code here
char seperator[] = "|";
int i;

i = 0;

char *token;

token = strtok("xxxx|ffff", seperator);

while( token != NULL )
{
AfxMessageBox(_T("token"),MB_OK);
// Get next token
token = strtok( NULL, seperator );
}
}
----------------------------------------------------------------

When I compile and build the application, there is no error shown. However, when i try to Click the OnBInsert Button, it does not function like what I expect which 2 message box will appear. It just do nothing, and then after i close the CNEWSERIALNO dialog. all the main form button cannot work include menubar.

Can someone help me ob this matter.

Thanks in advance.

Best Regards

 
Old May 2nd, 2006, 03:09 AM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have found another problem when casting. Below is my sample code:
-------------------------------------------------
UpdateData (TRUE);
CString sSerialNo(m_sSerialNo);
char input[] = (char)(LPCTSTR)sSerialNo;
-------------------------------------------------
m_sSerialNo is a member varibale of edit box. when i compile, I get this error.

C:\Documents and Settings\user1\My Documents\MobileInventory\NEWSERIALNO.cpp(57) : error C2440: 'initializing' : cannot convert from 'char' to 'char []'

how should I fix this, can someone pls help.

 
Old May 3rd, 2006, 01:49 AM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

problem solved.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Splitting a text string ghall202 Access 4 February 14th, 2008 05:45 PM
Splitting of string lily611 SQL Server 2000 3 March 19th, 2005 08:17 AM
string splitting qwjunk Classic ASP Basics 5 February 2nd, 2004 05:59 AM
splitting this string menesesg Classic ASP Basics 1 September 10th, 2003 12:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.