Examples of strings in c++ programing
All Contributions
How to Write a program that enter a data type string:
#include <iostream>
using namespace std;
int main()
{
string str;
cout << "Enter a string: ";
getline(cin, str);
cout << "You entered: " << str << endl;
return 0;
}
how to Write a program to read and display an entire line entered by user :
#include <iostream>
using namespace std;
int main()
{
char str[100];
cout << "Enter a string: ";
cin.get(str, 100);
cout << "You entered: " << str << endl;
return 0;
}
How to Write a program to display a string entered by user.
#include <iostream>
using namespace std;
int main()
{
char str[100];
cout << "Enter a string: ";
cin >> str;
cout << "You entered: " << str << endl;
cout << "\nEnter another string: ";
cin >> str;
cout << "You entered: "<<str<<endl;
return 0;
}
a string entered by user.
total contributions (4)
write a program to enter two strings and store them then show the entered strings: