Problem with code or Dev-C++ IDE???

This is a discussion on Problem with code or Dev-C++ IDE??? within the C Programming forums, part of the General Programming Boards category; Here is my code: Code: #include <stdio.h> main () { char letter; printf ("Enter a letter: "); scanf ("%c", &letter); ...

  1. #1
    Registered User dbyte's Avatar
    Join Date
    Jul 2003
    Posts
    15

    Question Problem with code or Dev-C++ IDE???

    Here is my code:
    Code:
    #include <stdio.h>
    
    main ()
    {
    char letter;
    
    printf ("Enter a letter: ");
    scanf ("%c", &letter);
    printf ("The letter you typed is %c\n", &letter);
    
    system("PAUSE");
    }
    When I compile the code I get no errors, but when I run the generated .exe I always get the same character outputted to the screen regardless of what I type; it looks like the symbol for pi, but with only 1 vertical line. My character map shows it in the Symbol fonts section, row 3 column 8.

    What am I missing? Does anyone else who uses this IDE have similar issues or any ideas on what may be causing this? I have tried disabling Norton while compiling & running the program, rebooting, deinstalling/reinstalling it, & downloading & installing a new [zipped] install file from the Dev-C++ website but it didnít change anything.

    Thanks in advance for any help.

    -Dbyte

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    The one problem in your code that is probably what's causing that to happen is that you're telling it to print the address of letter, not the value. You should only use & in printf() when you're telling it to show a string (ex. & string[0]). I'm not sure why it comes up with the same character every time though....

  3. #3
    Registered User dbyte's Avatar
    Join Date
    Jul 2003
    Posts
    15

    Thumbs up

    Salem & Draco,
    Thanks for helping out yet another newB guys. I made the settings changes and removed the '&' - VOILA! I actually have working code!!

    I'll be back here asking questions again soon, as I'm trying to write a C program to do zipped file backups & output the results to a log file (like Iomega but without the GUI, proprietary BS, or issues with different OS's).

    This site rules!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with progress code
    By JFonseka in forum C Programming
    Replies: 13
    Last Post: 04-25-2008, 05:03 PM
  2. Problem with my morse code program
    By justin87 in forum C++ Programming
    Replies: 1
    Last Post: 10-21-2007, 05:23 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Replies: 16
    Last Post: 08-23-2003, 09:22 PM

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