Hi,
I want to use an array str, while each array element str[i]
is an array of chars of fixed length, say 40;
The best way to handle this in C# is StringBuilder I guess,
but as legacy C++ code must communicate with my C# app, I
prefer only low-level primitive types, so chars here.
Of course, char [] str = new char[40]; will create an array
of 40 chars for me, but that's not what I want.
I need something like :
for (int i=0;i<50;i++)
{
char [] str[i] = new char[40];
}
I guess, but how to dimension the array str itself. By
using char [] [] .... ????
Confused with the double dimensions, one for the array
lenght of str , and one for the number of chars in each
array element ...
Some help would be nice.
Thanks,
Peter 4 1887
Peter wrote: Hi,
I want to use an array str, while each array element str[i] is an array of chars of fixed length, say 40;
The best way to handle this in C# is StringBuilder I guess, but as legacy C++ code must communicate with my C# app, I prefer only low-level primitive types, so chars here.
Of course, char [] str = new char[40]; will create an array of 40 chars for me, but that's not what I want.
I need something like :
for (int i=0;i<50;i++) { char [] str[i] = new char[40]; } I guess, but how to dimension the array str itself. By using char [] [] .... ????
Confused with the double dimensions, one for the array lenght of str , and one for the number of chars in each array element ...
Some help would be nice.
Thanks, Peter
Do a search for multidimensional arrays in the MSDN library.
You want something like:
char[,] myArray = new char[10,40];
Peter wrote: Hi,
I want to use an array str, while each array element str[i] is an array of chars of fixed length, say 40; (abridged) I need something like :
for (int i=0;i<50;i++) { char [] str[i] = new char[40]; }
You've got two options. If every char array is the same length, eg. 40.
You can use a multidimensional array:
char[,] str=new char[40,40];
If the arrays aren't the same length, you must use a jagged array which
is an array-of-arrays.
char[][] str=new char[40][];
for (int i=0; i<40;i++) {
str[i]=new string[i*2];
}
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Peter <An*****@work.nl> wrote: I want to use an array str, while each array element str[i] is an array of chars of fixed length, say 40;
The best way to handle this in C# is StringBuilder I guess, but as legacy C++ code must communicate with my C# app, I prefer only low-level primitive types, so chars here.
Of course, char [] str = new char[40]; will create an array of 40 chars for me, but that's not what I want.
I need something like :
for (int i=0;i<50;i++) { char [] str[i] = new char[40]; } I guess, but how to dimension the array str itself. By using char [] [] .... ????
Confused with the double dimensions, one for the array lenght of str , and one for the number of chars in each array element ...
char[][] str = new char[50][];
for (int i=0; i < 50; i++)
{
str[i] = new char[40];
}
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon,
I was waiting for your answer because I thought there should be something
else, luckily for my self-coinfidence you did not show that as well. (And
still I am not sure)
:-)
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JC |
last post by:
hi
i want to check a char in the char array
public void characters(char chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new...
|
by: pandapower |
last post by:
Hi,
I know about the equivalence of pointer and arrays.But my doubt
comes when its for multidimentional arrays.I have read the C faq but
still have some doubts.
Suppose I have a declaration as...
|
by: s.subbarayan |
last post by:
Dear all,
I encountered the following piece of program:
#include <stdio.h>
void strprint(char *str);
void main()
{
char *spr="hello";
strprint(spr);
}
|
by: Roman Mashak |
last post by:
Hello, All!
I wonder is it possible to define an array containing strings, not
single characters? What I want is array 'table' that will have N
elements, and every element is a strings tailoring...
|
by: Michael |
last post by:
Hi,
How to understand the difference between the following three.
My understanding is the number in bracket minus one is the max number
of chars to store in the char array , right?
...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
| |