Please Help!!!!!!!!

Easy People,


I need to know how to extract a single Character fro the string. At the moment the code moves the pointer to the third character along. so it shows "LO WORLD".


I need to be able to grab a single cha from the string.

Any ideas people ?


Thanks (code below)




char *Stcpy(char *dst, char *src)

{

char *p = dst;


while ((*p++ = *src++) != '')

;

return dst;

}




void main()

{

char *source= "HELLO WORLD";

char dest[80];


Stcpy(dest,source);

printf("I have %s
",&dest[3]);


}


Comments

  • All you need to do is think of the string not as a single variable on it's own, but as an array of individual characters.

    For instance, if you put this in your main function:


    printf("%c", source[6]);


    it would display:


    W


    I hope that helps!


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories