On 20 Feb 2007 13:04:20 -0800, "DanielJohnson" <>
wrote in comp.lang.c:
> On Feb 19, 11:02 pm, "mdh" <m...@comcast.net> wrote:
> > /***
> >
> > I wonder if anyone can see why this is not working as planned
> > ( concatenate n characters from t[] to s[]). I copy s[] to u[], then
> > add n characters to []u from t[]. When I debug, I see that u[] does
> > have the correct string, but when printed, it does not do so.
> > Thank you.
> > code below.
> >
> > ******/
> >
> > #include <stdio.h>
> > # define SIZE 1000
> >
> > int main () {
> >
> > void strncat( char *s, char *t, int );
> > void strcpy(char *s,char *u);
> >
> > int i=5;
> > char s[]="Now is the time for all good men";
> > char t[]="To be counted";
> > char u[SIZE];
> >
> > strcpy(u, s);
> > strncat(u, t, i);
> >
> > printf( "To the phrase: \"%s\"\n is added the first %d letters of the
> > phrase \"%s\"\n resulting in phrase: \"%s\" \n\n", s, i ,t, u);
> > return 0;
> >
> > }
> >
> > void strcpy(char *u, char *s){
> >
> > while ( *u++ = *s++);
> >
> > }
> >
> > void strncat( char *u, char *t, int i){
> >
> > while ( *u++);
> >
> > while ( (*u++ = *t++) && i-- > 0 );
> >
> > *u='\0';
> >
> >
> >
> > }- Hide quoted text -
> >
> > - Show quoted text -
>
> Please indent the code for better readability
Please learn how to post without appending those stupid strings about
"quoted text" and making them appear to be part of the post you are
replying to when they are not.
If you can't figure out how to use Google groups properly, either get
a real newsreader to post with, or don't post.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html