473,326 Members | 2,192 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,326 software developers and data experts.

split char*

I have a char *pszSomeData,

which is of the form:

*pszSomeData = "string1¬string2¬string3|abc1¬abc2¬abc3|" etc....

I need to call a function that accepts:

void CallMe(char* c1, char* c2, char* c3)
{
}

and would like to call it multiple times like so: CallMe(string1,string2,string3) and also CallMe(abc1,abc2,abc3)

I am more than familiar with how to do this using C#, but my very limited C++ does not extend this far.

Can anyone please advise?

Joseph
Jul 29 '09 #1
4 5859
donbock
2,426 Expert 2GB
I sounds like you need to parse the string pointed to by pszSomeData to create six new strings: string1, string2, string3, abc1, abc2, and abc3. Once you have the six new strings it is straightforward to invoke CallMe with the appropriate substrings.

To parse the input string you need to ...
  • Allocate memory for the six substrings.
  • Traverse the input string, appending each character (except the substring delimiters) to one of the six output strings.
Does this sound like what you want to do, or have I misunderstood what you're trying to accomplish?
Jul 29 '09 #2
Banfa
9,065 Expert Mod 8TB
Another important consideration is do the parameters to CallMe need to be char * or could they be const char *.
Jul 29 '09 #3
I hoped there was a means to do a split by | and then ¬, is this not possible?

Thanks,

Jospeh
Jul 29 '09 #4
donbock
2,426 Expert 2GB
@josephbyrns
Sure there's a way ... but you have to write the code to do it yourself.

What about that ¬ character? It isn't in the ASCII character set, so are you using an implementation-specific character encoding or are you using Unicode?


@Banfa
Good point. It is good practice to declare function arguments as 'const pointers' unless you intend the function to alter the thing being pointed at. This is especially true of char pointers so that you can pass string literals since they are typically implicitly const-protected.
Jul 29 '09 #5

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

Similar topics

4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
9
by: Java and Swing | last post by:
Say I have a string which contains numbers separated by a comma... such as "0,1,2,3,4,5"...I want to split the string at the commas and return an array containing, 0,1...5. Suggestions? I've...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
6
by: andrewcw | last post by:
The split function takes as a parameter what I understand as array of Char. I can define the delimiter like this: string innerText = new string; char chSplit={'='};...
14
by: Ron | last post by:
Hello, I am trying to parse a string on the newline char. I guess vbCrLf is a string constant. How can I parse my string - data - on the newline char? .... data += ASCII.GetString(buffer, 0,...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
1
by: mdefoor | last post by:
I've written the following sample to split a string into chunks. Is this the right approach or is there perhaps a better way to accomplish getting chunks of a string? #include <stdio.h>...
8
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
4
by: mjbauer95 | last post by:
Here is my function to split 2 strings. It has no errors but the function returns an array of lots of random characters. char * split(const char * original, const char * search) { char...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.