Signup/Sign In

C++ Program To Print A Full String Input using Keyboard

In this tutorial, we will understand that how to write or take input a full string usig the keyboard.

Program To Print A Full String Input Using Keyboard In C++

Before moving to the implementation part ,let's first have a absic look on what is string in C++.

String is a collection of characters. There are two types of strings commonly used in C++ programming language:

  • Strings that are objects of string class (The Standard C++ Library string class)
  • C-strings (C-style Strings)
#include<iostream>
#include<string.h>
using namespace std;
int main()
{   
  char a[20];
  int i,j;

  cout<<"\n\nEnter The String: ";
  gets(a);  
  cout<<"\n\nYour Entered String is Given Below \n\n";

  for(i=0;a[i]!='\0';++i)
  {
  cout<<a[i];
 }
 return 0;
}


Enter The String: Studytonight


Your Entered String is Given Below

Studytonight

Conclusion

Here, we have learnt the basic approach and C++ program implementation of strings that how can we input the strings using characters as a datatype.



About the author:
Nikita Pandey is a talented author and expert in programming languages such as C, C++, and Java. Her writing is informative, engaging, and offers practical insights and tips for programmers at all levels.