A program to perform string operations copy string

 Copy string



        In this example, we will  understand to perform string operations copy string and know how to write, compile and debug it in C language and also learn how to implement it in c.

        
        In order to do this you will need

  • Basic knowledge of c programming language.
  • As well as know how to operate codeblocks.        
    
    C does not support strings as a data type.It allows us to represent strings as character arrays.A string variable is any valid C variable name and is always  declared as an array of characters.

The general form of declaration of string variable:
char string_name[size];

strcpy() functions:

Description:
This function works almost like a string-assignment operator.

Syntax:
strcpy(string 1,string 2);
string2(source string) copies into string 1(destination string)


So let's begin with our program

1.Open a codeblocks software.

2.Open new empty file.

3.Copy and paste the code from below. 



A program to perform string operations copy string,c programming language,2021,basic codes,input output code




Input code- 

//Write a program to perform string operations copy string.

#include<stdio.h>
#include <string.h>
int main()
{
char str1[10]="INDIA";
char str2[10];
char str3[10];
strcpy(str2, str1);
strcpy(str3,"XYZ");
puts(str2);
puts(str3);
return 0;
}



Now simply build the code. Look for any error. Now run the code.
For output enter any number or character series you want and press enter key.


A program to perform string operations copy string,c programming language,2021,basic codes,input output code




Click the following button to download a program for Copy String







Thats it.Thank you for scrolling.


Post a Comment

If you have any doubt or suggestions.please let me know.

Previous Post Next Post

Ads by google

Ads by google