BrainDump
  Home arrow BrainDump arrow Page 4 - C: Strings
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

C: Strings
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-03

    Table of Contents:
  • C: Strings
  • Storing Strings
  • String Operations
  • Strcat()
  • Strcmp()
  • Strcpy()

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    C: Strings - Strcat()
    (Page 4 of 6 )

    If you wish to concatenate or join two strings together, you can use the strcat() function, like so:


    #include <stdio.h>

    #include <string.h>

    int main ()

    {

    char first[80]="Yippie";

    char second[90]="Hooray";

    char spacer[5]="n";

    printf(first);

    printf(spacer);

    strcat_s(first,second);

    printf(first);

    printf(spacer);

    printf(second);

    return(0);

    }

    This program creates three arrays. The first one, aptly named first, stores the value “Yippie.” The second array, named (you guessed it) second, holds the value “Hooray.” The third, titled “Spacer,” is used to insert a blank line between the text we will be printing.

    We start off printing the value of first, and then we print out the spacer. Next we use strcat_s() to join the values of first and second together. Note that this value gets stored in first, and the value of second stays the same. We then print out first again, to show its new value, then a spacer, and finally the array second, to show that it has not changed. The result is:

      Yippie

      YippieHooray

      Hooray

    More BrainDump Articles
    More By James Payne


       · Thanks for stopping by to read my article on C Strings. Here we discuss how to store...
     

    BRAINDUMP ARTICLES

    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC
    - VBScript: More Fun with the Date Functions
    - Vista Price Cuts Dissected




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway