Thread: masking problems

  1. #1
    Covenent Killer
    Join Date
    Jul 2005
    Posts
    26

    masking problems

    ok, here is the code i'm having problems with--
    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <conio.h>
    
    using namespace std;
    
    int main()
    {
    
    string input;
    char ch;
    while (ch = getch())
    {
        input.append(ch);
        cout << '*';
    }
    cin.get();
    }
    Error Message repeats: "Invalid conversion from 'char' to 'const char'"
    When I joined the Core, We didnt have any fancy Shmancy tanks! We had Sticks, TWO sticks and a rock for a whole platoon, And we had to share the rock! -- Sarge

    My Other Name Is Warhawk
    They Just Didn't let Me Have That Name...

  2. #2

  3. #3
    Covenent Killer
    Join Date
    Jul 2005
    Posts
    26
    thnx! that clears alot up... a little technical but nothing i cant fix up
    When I joined the Core, We didnt have any fancy Shmancy tanks! We had Sticks, TWO sticks and a rock for a whole platoon, And we had to share the rock! -- Sarge

    My Other Name Is Warhawk
    They Just Didn't let Me Have That Name...

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    > input.append(ch);
    Try:
    input.push_back(ch);

  5. #5
    Covenent Killer
    Join Date
    Jul 2005
    Posts
    26
    now by the sounds of it, it replaces the "*" with a backspace, then the user wont see what they enter, true?
    When I joined the Core, We didnt have any fancy Shmancy tanks! We had Sticks, TWO sticks and a rock for a whole platoon, And we had to share the rock! -- Sarge

    My Other Name Is Warhawk
    They Just Didn't let Me Have That Name...

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    No, it's equivalent to:
    Code:
    input = input + ch;

  7. #7
    Covenent Killer
    Join Date
    Jul 2005
    Posts
    26
    Quote Originally Posted by swoopy
    > input.append(ch);
    Try:
    input.push_back(ch);
    you cant use backspace though, i know that for a fact when my friends and I were working on this... we used that method, and when you backspace, it adds another star
    When I joined the Core, We didnt have any fancy Shmancy tanks! We had Sticks, TWO sticks and a rock for a whole platoon, And we had to share the rock! -- Sarge

    My Other Name Is Warhawk
    They Just Didn't let Me Have That Name...

  8. #8
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Or another alternative method could be using string streams

    Code:
    ...
    string input;
    stringstream strstream;
    
    while( ch = getch() )
    {
    strstream << ch;
    }
    input = strstream.str();
    ...
    just another alternative (with this you have to include stringstream )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  3. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM
  4. DIB masking
    By SAMSAM in forum Windows Programming
    Replies: 1
    Last Post: 02-03-2003, 10:22 AM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM