Hi,
I have a string variable which contains n number of comma delimited
elements and I would like to store each element into an array but I
could not figure how to do it.
for example, 1stitem,2nditem ,3rditem,4thite m, ..., nthitem
What would be the best way of storing the above string into an array
like
tempary[0]="1stitem"
tempary[1]="2nditem"
tempary[2]="3rditem"
tempary[3]="4thitem"
....
....
tempary[n-1]="nthitem"
thanks. 2 2531
gh wrote: I have a string variable which contains n number of comma delimited elements and I would like to store each element into an array but I could not figure how to do it.
for example, 1stitem,2nditem ,3rditem,4thite m, ..., nthitem
What would be the best way of storing the above string into an array like
tempary[0]="1stitem" tempary[1]="2nditem" tempary[2]="3rditem" tempary[3]="4thitem" ... ... tempary[n-1]="nthitem"
You don't say if these are static values, or you want a general purpose
set of mutable strings.
I typically build a array of pointers to some char arrays (or char
pointers) of sufficient size (determined at runtime or compile time --
your choice depending on your application).
For example, I will often declare a char **, allocated space for the
number of char * items I want to store in it (adding room for one if I
want the notion of the last one in the "list" being null as a marker)
and then allocate room for each string as needed, associating them with
the container pointer "array".
I'm hand-waving here, but think of what "**argv" or "*argv[]" means.
gh wrote: I have a string variable which contains n number of comma delimited elements and I would like to store each element into an array but I could not figure how to do it.
for example, 1stitem,2nditem ,3rditem,4thite m, ..., nthitem
What would be the best way of storing the above string into an array like
tempary[0]="1stitem" tempary[1]="2nditem" tempary[2]="3rditem" tempary[3]="4thitem" ... ... tempary[n-1]="nthitem"
Ideally suited for the toksplit() function I published here a short
time ago. But read and heed my sig. below.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RelaxoRy |
last post by:
Reposted (not sure if got sent)
I have results being displayed each with its own checkbox name
"selected" and value "id".
When someone checks a checkbox, and then continues to page through the
data (mysql select), I want that checkbox to be remembered. Basically
I want the user to have multiple selections of checkboxes when paging...
|
by: Arne |
last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39
Hi,
I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.
Now here is the problem:
|
by: CJM |
last post by:
In an application I'm working the user has the opportunity to record the
despatching of one or more items with serial numbers.
For each item they despatch, they have to chose the serial no that they want
to despatch from a list of available ones. In many cases, these items will
be of the same time, so the dropdown of available serial no's...
|
by: Vagabond Software |
last post by:
Apparently, the Split method handles consecutive tabs as a single delimiter. Does anyone have any suggestions for handling consecutive tabs?
I am reading in text files that contain lines of tab-delimited data. I was using string stringArray = lineOfText.Split('\t') to automatically populate an array used to populate the values in a new...
|
by: Ot |
last post by:
I have a Tab delimited file: Field1<tab>Field2<tab>...<Field20><crlf>
There must be an easy way to break this apart, but I haven't found it yet.
Can anyone help?
Regards,
Ot
| |
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...
field1...field2...field3...
|
by: VMI |
last post by:
I'm parsing a comma-delimited record but I want it to do something if some of
the string is between "". How can I do this? With the Excel import it does
it correct. I'm using String.Split().
Basically, this is what I want to do: Use string.Split() on the whole string
UNLESS the string is in between double-quotes. The part of the string...
|
by: Kyro |
last post by:
New to C# (migrating from Delphi) and I'm not sure how to get a
delimited string into an array of string.
input: string looks like - 01-85-78-15-Q11
output: an array with elements - 01,85,78,15 etc...
Is there some sort of easy one liner that does this? Hard to search
the help files for anything that would assist me in doing...
|
by: Jim |
last post by:
Hello:
I have a variable which contains a comma delimited list contained in a
database variable e.g. "5,6,9,10,55,42" - I want to hand this list to
an array function to get it to populate an array, such as follows
(where rst!Q10ACode is the database variable):
Dim ListArray as Variant
Dim Substring1 as String
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |