0

kindly help me n tell me in 2 dimension array wen we r taking words as input then cin would be used or getch..???plz replay.me waiting

Edited by anumiqbal

5
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by WaltP
0

In the absence of specific details about what you're trying to do, cin is a perfectly good way to input words in C++.

Edited by Bob

1

cin would be used or getch

First of all, getch() is not a standard function. Avoid using it.

Secondly, getch() won't echo what user have entered, that is it will not show in screen what user has entered.

Third, use cin when you are taking just a single word, because if you use space in between, cin will not work properly. It would only take the part before the space.

# include <iostream>

 using namespace std;

 int main()
 {

    char c[100];

    cin >> c;

    cout << c;
 }

Run this and see what happen. When you want to enter a sentence ( that is spaces will be present ) , use fgets().

Edited by np complete

Votes + Comments
getline() can also be used
1

When you want to enter a sentence ( that is spaces will be present ) , use fgets().

Don't you mean cin.getline()? This is C++...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.