Thread: CString

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12

    CString


    Is it possible to create an array of CStrings.

    CString cstring[];

    I declared it like a normal array and used a for loop reading from a file to fill the array.

    for( indx =1; indx <= length; indx++){

    if( indx == 1){
    startTagPos = 1;
    }

    if((( inputValue == '!') || ( inputValue == '?')) && (startTagPos != indx)){
    arr[indx]= tagCS;
    arr[indx] = tagCS;
    cout << arr[indx] <<endl;
    cout <<arr[(indx-1)]<<endl;
    tagCS = inputValue;
    }
    else{
    tagCS += inputValue;
    }
    inputFilename >> inputValue;
    }

    output:
    !$00003

    ?$0006

    !$0001001

    !$0002001

    The blank lines represent the print of the previous value in the array and there is nothing there.

    Any suggestions would be greatly appreciated!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    Yes, you can create arrays of CStrings just like any other object:

    CString myArray[ 32 ];

    I'm not sure what else you're asking. If you're wondering about the weird printing, the reason your output consists of memory addresses rather than strings is that CString doesn't have a << operator that's designed for cout. However, you can cast a CString to a character array, which does have a << operator that works well with cout. So change your cout logic to this and it should display strings:

    PHP Code:
    cout << (LPCTSTRarr[indx] << endl;
    cout << (LPCTSTRarr[(indx-1)] << endl
    I don't know if this answers your question but I hope it helps.
  4. #3
  5. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    In the future please use an appropriate subject title. You can refer to the sticky thread at the top of this forum for more information on how to post a question.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12
    Thanks. Sorry about the subject.

IMN logo majestic logo threadwatch logo seochat tools logo