TH> ML> DIM K$(100) AS STRING * 256
TH> Uh, you mean like:
TH> char K[256][100];
TH> Or what?
That would be K[100][256]; :)
Better off using dynamic allocation on that.
char **K = new char*[100];
for(int string = 0; string < 100; string++)
K[string] = new char[256];
for(string = 0; string < 100; string++)
delete []K[string];
delete []K;
Or even better...
class MyString {
public:
MyString(){ S = new char[256]; }
~MyString(){ delete []S; }
char *StringAddress(){ return S; }
private:
char *S;
}
MyString *K = new[100];
delete []K;
Making a class of it removes the need of a loop to
initialize and destruct your string arrays.
In addition to this, you have the ability to add all sorts
of useful string handling routines to your class, such as
overloaded assignment using =, overloaded concatenation using
+, mid, left, right, trunc, pad, uppercase, lowercase, and
comparison with or without case sensitivity using ==.
You can have it accept int, long, float, char, char*, and
anything else, including specialty items specific to your
application, such as a specific struct or data type.
This is where C++ really shines over C. You can construct a
class to handle the creation and maintenance of strings or
other data objects, and not need to construct the code for
every instance of the use of that type of object, as you
would with the first example, using a loop to initialize
an array of strings.
> ] Presently orbiting Mars in a Supertramp album...............
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|