Results 1 to 6 of 6

Thread: Char array arrays

  1. #1
    o0Jon0o
    Guest

    Unhappy Char array arrays

    Is there any way of putting a whole word (at once) in a char double array:

    char[5][5];

    I can't use a string array as the function (SystemParametersInfo) will not accept it and I don't know how to convert it to a single char array.

    Thanks

    Jon

  2. #2
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    you can use:

    PHP Code:
    char *mystring[5]=new char[<maxstringlength>];

    strcat(mystring[0],"Hello"); 
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    a two dimensional array 5x5 is the same as a single dimensioned array of 25, array[16] will for isntance point to element 3,1 (3*15+1)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    o0Jon0o
    Guest
    nabeels786, It's probably me being dumb but your code doesn’t compile. I've tried changing parts of it and compiled it under VC++ and Builder 4 but to no avail.

    #include <iostream.h>
    #include <string.h>

    void main(){
    char *mystring1[5]=new char[15];
    strcat(mystring[0],"Hello");
    }

    I want to do the same as this:

    string mystring[10];
    mystring[1] = "Hello";
    mystring[2] = "world;

    but with chars as my function doesn't accept strings

    or maby just convert mystring[2] into a char array ether way's good.

    Sorry for all the stupid questions

    Jon

  5. #5
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    string->char

    Code:
    string myString[10];
    myString[0] = "Hello";
    myfunc (myString.c_str());
    VS.NET 2003

    Need to email me?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Works only if the function wants a const char* or LPCTSTR or LPCSTR.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width