Thread: My program is displaying.....actual hearts

  1. #1
    Registered User
    Join Date
    Nov 2005

    My program is displaying.....actual hearts

    I'm writing a program which takes a surname, and assigns a phonetic code to the name(SOUNDEX encoding)

    Anyway, for certain names, the program is displaying a little 'heart' character instead of a number. There is nothing in the program directly instructing it to display a 'heart' character.
    What normally causes this?

    I don't want to display the code as it is coursework and I don't want direct help with the code.


  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Quote Originally Posted by Wiretron
    What normally causes this?
    Attempting to print the character representation of an integer value such as 3 rather than the intended '3'.
    #include <stdio.h>
    int main(void)
       int value = 3;
       printf("%%d: %d, %%c : %c\n", value, value);
       value = '3';
       printf("%%d: %d, %%c : %c\n", value, value);
       return 0;
    /* my output
    %d: 3, %c : 
    %d: 51, %c : 3
    Last edited by Dave_Sinkula; 11-08-2005 at 05:42 PM. Reason: Added code.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Make sure you are initializing the variable that is holding this "heart" to zero. Like if it was a C-style string, it would be initialized like this:
    char var[256]={0};
    If it's not initialized to zero then it may have that junk in it.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You probably just have %c instead of %d (or %i, which is the same thing as %d).

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Wierd problem
    By Olidivera in forum C++ Programming
    Replies: 17
    Last Post: 05-06-2005, 04:50 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Displaying pointer's actual values in inheritance
    By Poof in forum C++ Programming
    Replies: 14
    Last Post: 07-29-2004, 07:34 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM