Re: How to divide and join variables of char type ??

From: Elephant (cleaner_at_codocadNOSPAM.com)
Date: 01/23/04


Date: Fri, 23 Jan 2004 17:10:51 +0100

Not exactly clear what you want, maybe you can use memcpy()?

char c1[10];
char c2[5];
char c3[15];

// Copy first 5 char's from c1 to c2.
memcpy( c2, c1, sizeof(char)*5 ); // sizeof(char)*5 = 5.

// Copy last 5 char's from c1 to 2.
memcpy( c2, &(c1[5]), sizeof(char)*5 ); // &(c1[5]) == c1+(sizeof(char)*5).

// Join with other variables?
// Copy c1 and c2 to c3.
memcpy( c3, c1, sizeof(char)*10 );
memcpy( &(c3[10]), c2, sizeof(char)*5 );

"KPG" <mstepien@kpg.pl> schreef in bericht
news:bur62r$15c$1@nemesis.news.tpi.pl...
> I have char variable, for example
> char c[10];
> and I would like to divide this variable
> on two others char variables
> or join with oher char variables/
>
>
>
>
>



Relevant Pages

  • Re: char as array index gives warning in gcc
    ... is extremely limited I use char variables wherever I ... For example I use chars as array indices in dozens of places: ... Indexing with a character is one of those dubious things. ...
    (comp.lang.c)
  • char as array index gives warning in gcc
    ... Because RAM space is extremely limited I use char variables wherever I can. ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • char as array index gives warning in gcc
    ... Because RAM space is extremely limited I use char variables wherever I can. ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • char as array index gives warning in gcc
    ... Because RAM space is extremely limited I use char variables wherever I can. ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • char as array index gives warning in gcc
    ... I'm writing C code for an Atmel AVR micro controller. ... Because RAM space is extremely limited I use char variables wherever I can. ...
    (comp.lang.c)