How would I got about fixing this?

This is a discussion on How would I got about fixing this? within the C++ Programming forums, part of the General Programming Boards category; Code: key_press = getch(); strcat (spell_word, key_press); This doesn't work because, getch() requires key_press to be a CHAR and strcat() ...

  1. #1
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,068

    How would I got about fixing this?

    Code:
    key_press = getch();
    strcat (spell_word, key_press);
    This doesn't work because, getch() requires key_press to be a CHAR and strcat() requires key_press to be a CONST CHAR (String).

    Any way around that?
    Sent from my iPadŽ

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Something like this
    Code:
    key_press = getch();
    for (int i=0;spell_word[i];i++);
    spell_word[i]=key_press
    spell_word[i+1]=0;
    You could also keep track of the length of the string somewhere to be more efficant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing Z-order on a modeless dialog?
    By Viper187 in forum Windows Programming
    Replies: 6
    Last Post: 06-20-2008, 07:10 PM
  2. Fixing incorrect extern declaration
    By cunnus88 in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2007, 03:55 PM
  3. Fixing my (Stupid) IE Menubar
    By civix in forum Tech Board
    Replies: 2
    Last Post: 01-04-2004, 01:22 AM
  4. Fixing Laptops
    By zdude in forum Tech Board
    Replies: 5
    Last Post: 06-16-2003, 01:56 AM
  5. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 05:02 PM

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