Results 1 to 2 of 2

Thread: help with character array

  1. #1

    Thread Starter
    Lively Member jk9694's Avatar
    Join Date
    Dec 2001
    Posts
    78

    Question help with character array

    Ok i have a character array *chararray[]={"kjshf", ...........}, i am trying to get this information into another array where test[0]=k, test[1]=j and so on, but i am not having any luck on accomplishing this task can any one give me a hand with this??

    I need to be able to read each character within chararray as a single after it outputs kjshf to the screen then i tried test=chararray[x] but i am having no luck with this.

    Have a great day!!

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Two ways:
    Code:
    // #1
    #include <string.h>
    strcpy(test,chararray);
    // #2
    #include <stdlib.h>
    char *buf, *s;
    buf=chararray;
    s=test;
    memset(s,0x00,sizeof(test));
    while(*buf!=0x00) *s++=*buf++;
    not sure what you want.

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