PDA

Click to See Complete Forum and Search --> : help with character array


jk9694
Aug 20th, 2002, 06:54 PM
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.

jim mcnamara
Aug 21st, 2002, 06:47 AM
Two ways:

// #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.