What compiler should I use to allow the user to input the value of a string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What compiler should I use to allow the user to input the value of a string?

I've previously tried to write a program that would allow the user to input the value of a string. I was told that I needed to use a certain compiler in order to do that. Does anyone know what compiler I should use?

4th Nov 2016, 1:26 PM
Indie Geek
Indie Geek - avatar
2 Answers
0
No, It's not about compiler. Maybe you mean library? #include <iostream> #include <string> //This one. using namespace std; int main(){ string myString; getline(cin, myString); cout myString; return 0; } getline() means that you read the whole line, not only one word like cin >> myString; would do. For example: cin >> myString; Input: Today is Friday. Output: Today getline(cin, myString); Input: Today is Friday. output: Today is Friday. IDE(Where you can write and compile your code) like CodeBlocks does not require <string> library when you don't use any string functions like strcpy() and so on. In other IDE's like Visual Studio you need <string> library whenever you use string data type.
4th Nov 2016, 1:44 PM
Karolis Strazdas
Karolis Strazdas - avatar
0
Thanks so much! You're right, I did mean library.
4th Nov 2016, 1:46 PM
Indie Geek
Indie Geek - avatar