Pasting data from clipboard

This is a discussion on Pasting data from clipboard within the C++ Programming forums, part of the General Programming Boards category; My users will be copying in a string about 50 characters long, which the program will decrypt. I have this ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Location
    Newcastle Australia
    Posts
    8

    Pasting data from clipboard

    My users will be copying in a string about 50 characters long, which the program will decrypt. I have this working fine in a Javascript version. In C++ it's a different story. How can they paste this string from the clipboard into the application?

    This ...
    Code:
    string coded;
    cout<<"Copy in the string";
    cin>>coded;
    cin.get();
    cout<<"You entered: "<<coded;
    cin.get();
    ... works for typing in the string but copying and pasting just outputs "You entered: ^v"

    Is this moderately possible for someone new to C++ ??

    Thanks

  2. #2
    Cat Lover
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109
    Well, easiest way would be to have them copy it to a file, then read it in from the file probably.

    You can find a bunch of tutorials on file I/O around the place, just google for them.

    You'd want something like
    Code:
    #include <fstream>
    #include <iostream>
    
    using namepsace std;
    
    int main()
    {
        ifsttream in_file;
        in_file.open("file name here");
        //Now you can use in_file like cin to get the file contents basically
    }

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can right click on the console window to paste.

  4. #4
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    How do you have it in JavaScript? Otherwise do you want to do this?:
    Code:
    char coded[50];
    cout << "Copy in the string";
    cin >> coded;
    cin.get();
    cout << "You entered: " << coded;
    cin.get();
    Well, i'm not sure thats exactly what you wanted, but hey, I'm new from JavaScript too. In fact, I dont even know what cin.get() even does!
    Adam

  5. #5
    Registered User
    Join Date
    Sep 2005
    Location
    Newcastle Australia
    Posts
    8
    Thanks Dweia.

    This worked.

    Actually I/O was the very next cprogramming tutorial I had to look at but I thought I was getting in too deep.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  2. Replies: 3
    Last Post: 04-18-2008, 10:06 AM
  3. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-27-2005, 11:59 PM
  4. Dynamic data members?
    By confusalot in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2005, 10:15 AM
  5. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 02:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21