0

Hello,

In some functions of my program this code doesn`t work normally

string w1;
        string w2;

        cout<<"1st msg: Enter 2 words: ";
        getline(cin,w1);
        cout<<endl;

        cout<<"2nd msg: Enter 2 words: ";
        getline(cin,w2);
        cout<<endl;

        cout<<endl<<"w1: "<<w1<<endl;
        cout<<"w2: "<<w2<<endl<<endl;

But when i run it is some functions(except main and some others) of my program shows other output.

1st msg: Enter 2 words:
2nd msg: Enter 2 words: word1 word2


w1:
w2: word1 word2

My variables are again local, any ideas whats the problem ?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Ryaether
0

Are you showing us the part of your code that works?
Because I don't see any problems.

you entered nothing followed by the return key signaling a new line meaning an empty string was placed in w1, it then went on to capture the next line where you entered in word1 and word2 which it stored in w2

I am not understanding what problem you are having. What output were you expecting to get?

Edited by Ryaether: clarifying

0

i send you the code because is big to post it here

0

I'm sorry but I am not going to download anything I do not know the contents of (especially from rapidshare). Please post the relevant parts here and maybe someone can help you.

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.