Horje
Write C++ program to copy one string to another string using pointers Code Example
Write C++ program to copy one string to another string using pointers
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char strOrig[100], strCopy[100], i=0;
    cout<<"Enter the string: ";
    gets(strOrig);
    while(strOrig[i]!='\0')
    {
        strCopy[i] = strOrig[i];
        i++;
    }
    strCopy[i] = '\0';
    cout<<"\nEntered String: "<<strOrig;
    cout<<"\nCopied String: "<<strCopy;
    cout<<endl;
    return 0;
}
Write C++ program to copy one string to another string using pointers
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char strOrig[100], strCopy[100];
    char *origPtr, *copPtr;
    cout<<"Enter the string: ";
    gets(strOrig);
    origPtr = &strOrig[0];
    copPtr = &strCopy[0];
    while(*origPtr)
    {
        *copPtr = *origPtr;
        origPtr++;
        copPtr++;
    }
    *copPtr = '\0';
    cout<<"\nEntered String: "<<strOrig;
    cout<<"\nCopied String: "<<strCopy;
    cout<<endl;
    return 0;
}




Cpp

Related
C++ fill string with random uppercase letters Code Example C++ fill string with random uppercase letters Code Example
CSES Problem Labyrinth Code Example CSES Problem Labyrinth Code Example
time complexity calculator online Code Example time complexity calculator online Code Example
"how we write a program for" time swap" in c plus plus only with string" Code Example "how we write a program for" time swap" in c plus plus only with string" Code Example
find the smallest window in a string containing all characters of another string Code Example find the smallest window in a string containing all characters of another string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14