Advertisement Remove all ads

Write a Program in C++ to Accept a String from Keyboard and Copy String into Another String Without Using the Library Function. - Computer Science 1

Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Answer in Brief

Write a program in C++ to accept a string from keyboard and copy string into another string without using the Library Function.

Advertisement Remove all ads

Solution

#include<iostream.h>
#include<conio.h>

int main()
{
  char s1[100], s2[100], i;
  clrscr();
  cout<<"Enter string s1: ";
  cin>>s1;
  for(i=0; s1[i]!='\0'; ++i)
  {
    s2[i]=s1[i];
  }
  s2[i]='\0';
  cout<<"String s2: "<<s2;
getch();
}
Concept: C++ Programming
  Is there an error in this question or solution?

APPEARS IN

Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×