Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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 = '';
    cout<<"
Entered String: "<<strOrig;
    cout<<"
Copied String: "<<strCopy;
    cout<<endl;
    return 0;
}
Comment

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]!='')
    {
        strCopy[i] = strOrig[i];
        i++;
    }
    strCopy[i] = '';
    cout<<"
Entered String: "<<strOrig;
    cout<<"
Copied String: "<<strCopy;
    cout<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ string to integer without stoi 
Cpp :: prime number in c++ 
Cpp :: point is on line 
Cpp :: locate specific string letters c++ 
Cpp :: c++ print every element in array 
Cpp :: separating class into header and cpp file 
Cpp :: convert decimal to binary c++ 
Cpp :: c++ create threads 
Cpp :: clear console c++ 
Cpp :: lopping over an array c++ 
Cpp :: mpi_bcast 
Cpp :: lcm function c++ 
Cpp :: c++ code for selection sort 
Cpp :: find in set of pairs using first value cpp 
Cpp :: count occurrences of character in string c++ 
Cpp :: input 2d vector c++ 
Cpp :: prints out the elements in the array c++ 
Cpp :: http.begin arduino not working 
Cpp :: how to get length of a file in c++ 
Cpp :: loop through a vector in c++ 
Cpp :: two pointer in c++ 
Cpp :: how to create array with not constant size in cpp 
Cpp :: c++ initialize multidimensional vector 
Cpp :: create file c++ 
Cpp :: clear the input buffer in cpp 
Cpp :: casting c++ 
Cpp :: matrix in vector c++ 
Cpp :: run cmd command c++ 
Cpp :: how to code string to int converter c++ 
Cpp :: To Lower Case leetcode solution in c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =