-->
Showing posts with label WAP to copy a string using strcpy().. Show all posts
Showing posts with label WAP to copy a string using strcpy().. Show all posts

WAP to copy a string using strcpy().

using turboc++
-------------------------------------------------------------------------------------------
//WAP to copy  a string  using(strcpy()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%[^\n]s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    strcpy(st1,st);//copying a string into first
    printf("copied string =%s\n",st1);//prints the copied name
    getch();
    return 0;
}

---------------------------------------------------------------------------------------
using codeblocks
-------------------------------------------------------------------------------------------------------------
//WAP to copy  a string  using(strcpy()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%[^\n]s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    strcpy(st1,st);//copying a string into first
    printf("copied string =%s\n",st1);//prints the copied name
    return 0;
}