why getline is not working on string array


1
2
3
string yow[3][2];
    getline(cin,yow[0][1]);
    cout<<yow;


why is it not working?
Last edited on
cout is demanding to be more specific
hello ,

just use ( std :: ) before getline() or use ( using namespace std;) before main function

like this

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>

using namespace std;
int main ()
{
     string yow[3][2];
     getline(cin,yow[0][1]);
     cout<<yow;

     return 0;
}


here is output of this code

[[, ], [, ], [, ]]


see the online output of any code at this page :: http://codepad.org
choose your programming language and put your code in that form , then press submit
after a while you will see the output !!!
Last edited on
You need to specify what element of your array you want to print.
here is output of this code
[[, ], [, ], [, ]]

No. It should ouptut the address of yow variable. Any other sesult can be only cause by non-standard extension. Check on online compilers which are sane (or at least tells which compiler they use):
http://ideone.com/7vhUVI
http://coliru.stacked-crooked.com/a/0400265bf7a49221
Those two do not allow to link directly to the code:
http://www.compileonline.com/compile_cpp11_online.php
http://melpon.org/wandbox/
your right MiiNiPaa

program will gets a line ( string ) as an input , then prints the address of yaw variable

for example :

input :1654654654
output : 0x7fff1e9653f0

but that website......

Sorry guys !!!
@jib even if i specify the output of the array it still gives me incorrect results
Show your updated code.
@miinPaa ill send you my code as a pm
the admin pin number is 0000
1
2
3
cin>>name[counter][0];
cout<<"\tEnter Name:";
getline(cin,name[counter][1]);
Here is the problem
http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction
were you able to correct the my codes?
thanks i was able to do it but is there any other way because the <limits> was not discussed to us yet
Answer gives you 2 solutions and describes why second one is superior. Why everyone uses first one?

Use std::cin >> ws;
Alternatively, you can just pass large number (like 1000) as ignore() first parameter.
cout is demanding to be more specific
1
2
3
string yow[3][2];
    getline(cin,yow[0][1]);
    cout<<yow[0][1]; 
Topic archived. No new replies allowed.