473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

evc++: splitting string into array using strtok

13 New Member
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::O nBInsert()
{
// TODO: Add your control notification handler code here
char seperator[] = "|";
int i;

i = 0;

char *token;

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

while( token != NULL )
{
AfxMessageBox(_ T("token"),MB_O K);
// 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
May 2 '06 #1
2 8713
bluebeta
13 New Member
Hi,

I have found another problem when casting. Below is my sample code:
-------------------------------------------------
UpdateData (TRUE);
CString sSerialNo(m_sSe rialNo);
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\Mobil eInventory\NEWS ERIALNO.cpp(57) : error C2440: 'initializing' : cannot convert from 'char' to 'char []'

how should I fix this, can someone pls help.
May 2 '06 #2
bluebeta
13 New Member
problem solved.
May 3 '06 #3

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

Similar topics

26
808
by: Kai Jaensch | last post by:
Hello, i am an newbie and i have to to solve this problem as fast as i can. But at this time i don´t have a lot of success. Can anybody help me (and understand my english :-))? I have a .txt-file in which the data is structured in that way: Project-Nr. ID name lastname 33 9 Lars Lundel 33 12 Emil Korla
3
522
by: Kai Jaensch | last post by:
Hello, i am an newbie and i have to to solve this problem as fast as i can. But at this time i don´t have a lot of success. Can anybody help me (and understand my english :-))? I have a .txt-file in which the data is structured in that way: Project-Nr. ID name lastname 33 9 Lars Lundel 33 12 Emil Korla
10
1867
by: Eric BOUXIROT | last post by:
hi there, i'm working on a smart application project on VB.NET. i must call API (custom eVC++ DLL) but i have some trouble with mashalas attribute..... i have copy/past a sample on msdn help but it's not working.. IDE says "unknown 'mashalAs' attribute".....and i don't know why.... i have try exactly the same code on a normal windows project and it work (compile) fine...
13
1991
by: Pedro Pinto | last post by:
Hi there. I'm trying to do the following. I have a string, and i want to separate it into other halves. This is how it should be: char string = "test//test2//test3"; were // is the part were i want to separate it and store on a
29
4229
by: Andrea | last post by:
I want to write a program that: char * strplit(char* str1, char *str2, char * stroriginal,int split_point) that take stroriginal and split in the split_point element of the string the string into two other strings, example:
2
3273
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to lines it worked quite well but srttok isnot working for multiple blank or commas. Can strtok do this kind of splitting if it cant what should i use . Unal
3
2937
by: Alexander Adam | last post by:
Hi! I've got an input wchar_t array in a callback function from expat: void my_callback(const wchar_t* data); Additionally, I got a second function that I need to call within my callback with: void my_call_to(const wchar_t** arr);
6
5184
by: Studlyami | last post by:
Okay, i have developed a file parser in C++ that i am trying to being into a c# program which is proving to be a lot more difficult than i thought. first i scan a file (which i opened using a streamreader) until i find a keyword that i specified. Then i want to grab the items after that keyword and do a switch on them. In C++ it looked something like this char* FileToken; char LineBuffer; while (Test != NULL) //i haven't reach eof....
0
9669
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
9515
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
10427
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
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.