Newsgroups: comp.lang.c Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!alliance!darwinl From: darwinl@alliance.uucp (Darwin Ling) Subject: Re: help with strcat Message-ID: <1991Jun5.152229.14387@alliance.uucp> Organization: Alliance Technologies, Inc. References: <1991Jun4.210209.28463@ux1.cso.uiuc.edu> Distribution: comp Date: Wed, 5 Jun 91 15:22:29 GMT In article <1991Jun4.210209.28463@ux1.cso.uiuc.edu> gordon@osiris.cso.uiuc.edu (John Gordon) writes: >cshort@haywire.crl (Spmg*d, Lord of Potted Meat Product) writes: > > >>hi > >>could someone show me some example code to take >>two char strings and combine them into another char >>string. > >char *str1 = "Joseph went"; >char *str2 ' " to the store."; >char str3[100]; > >strcat(str3, str1); /* tacks str1 onto the end of str3 */ >strcat(str3, str2); /* tacks str2 onto the end of str3 */ > >/* str3 should now be "Joseph went to the store." */ > > >--- >John Gordon >Internet: gordon@osiris.cso.uiuc.edu #include > gordon@cerl.cecer.army.mil #include Or even easier do sprintf (str3, "%s%s", str1, str2);