Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-28-2007, 05:15 AM   #16
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453
Blog Entries: 3

Original Poster
Rep: Reputation: 40
Cool I've got the solution by myself , but thanks anyway

After dedicating a full time for this Catch 22 , I got the remedy to the problem.
googling , testing ,testing ,testing and testing Is the ultimate recipe in this business (and most definitly in any other field as well)
Hell , This is C++ programming ! you either fire up your compiler and probe the code or you can just rename your title to anything else than a "coder"

well , someone before just asked me to giving him a note when I find a smarter solution .

wait , should i license that?? ....nah no need...
So here it's , have fun and educate yourselves! :

#include <iostream>
using namespace std;

int main(){
	char x[10];
		cout<<"Enter Message:";
                        //I'm the magic line 
		cout<<"Message is:"<<x<<endl;
	return 0;
according to the 2003 standard update (and how i hate them)

Ooops , someone else just post this before me , should have clicked "post" quicker LOL

Last edited by entz; 03-28-2007 at 05:19 AM.
Old 03-28-2007, 05:39 AM   #17
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Originally Posted by entz
well , someone before just asked me to giving him a note when I find a smarter solution .
Actually it was you who asked...

The important point is that the code was doing what it should. Because you wanted a different behaviour it was necessary to tell the stream to ignore the remaining characters.

I'm glad that you managed to find a solution so that your code will behave the way you want it to.

Last edited by graemef; 03-28-2007 at 05:40 AM.


getline, ignore

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++::std::cin adilturbo Programming 3 07-03-2006 12:22 PM
How to cin >> string? kornerr Programming 2 11-01-2005 04:58 AM
cin.ignore Xiangbuilder Programming 4 10-08-2003 08:57 PM
g++ and cin.getline() codeviking Programming 8 07-03-2003 08:42 AM
cin.getline adam_boz Programming 6 10-02-2002 09:57 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:35 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration