Thread: Run-Time Check Failure #2 help

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    2

    Run-Time Check Failure #2 help

    for some reason my variable 'character' is causing this message to pop up.

    - Run-Time Check Failure #2 - Stack around the variable ' character ' was corrupted.

    here is the code.


    #include "stdio.h"
    #include "stdafx.h"
    #include "stdlib.h"
    #define LINE "_____________________"
    #define TITLE "KEYBOARD"
    #define AUTHOR "GROUP NINE"


    int main()


    {
    char character= ' ';


    printf("\n \t %s \n \t %s \n", LINE, TITLE); /* PROGRAMME HEADER */
    printf("\t by %s \n \t %s \n\n", AUTHOR, LINE); /* PROGRAMME HEADER */

    printf("Welcome toProgramme Beta\n\n");
    printf("Enter any one keyboard character: ");
    scanf_s( "%C", &character);


    Please can someone help me correct this.

    Thank You.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    scanf_s( "%C", &character);
    Format specifiers are case sensitive, that should be %c, not %C.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    2
    Cant believe i didnt see that.

    Cheers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Run time error?
    By shwetha_siddu in forum C Programming
    Replies: 6
    Last Post: 04-21-2009, 01:37 PM
  2. Replies: 12
    Last Post: 01-08-2009, 12:15 PM
  3. Replies: 7
    Last Post: 11-26-2007, 01:11 PM
  4. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 07:11 AM
  5. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 06:51 PM