Thread: Somthing with string

  1. #1
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133

    Somthing with string

    Hi.
    Is there a way to read something from the Win 32 Console screen that is already been printed something like this:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        char cstring[100];
        
        cout<<"hi";
        cin.getline( hopesit, 100 );
        cin.get(); 
    }
    My idea is that he would read the "hi" printed in the screen and you don't need to hit enter, just that he uses "hi" as cstring. Is there a way to do that, thx.

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	char cstring[100];
    	
    	cout<<"hi";
    	cstring = "hi";
    	cin.get(); 
    }
    I guess I didn't understand...
    [C++]
    IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
    2nd compiler: g++ (GCC 3.4.3/4.0.0)
    3rd compiler: Borland 5.5
    [C#]
    IDE: Microsoft Visual C# Express 2005
    2nd IDE: SharpDevelop
    2nd compiler: csc in Command Prompt
    .NET Framework: 2.0
    [PHP]
    Core: 5.1.0 beta 3
    IDE: PHPEdit
    2nd IDE: Notepad
    Favourite extensions: exif,gd2,mysql
    Favourite PEAR packages: DB, XML_RSS, ID3
    Favourite databases: SQLite, MySQL

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    sorry i dont know why i posted this

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
         string cstring ("hi");
         cout << cstring << endl;
         cin.get();
         return 0;
    }

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You wanted to write to the input buffer so that it would be read by the getline? Crazy talk! (a.k.a. I am not aware of any such thing). However, the prospect of saying std::cin << "hi"; is pretty funny.

  5. #5
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    Sorry it's hard to explain, I'll get back to it tomorrow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM