Run-Time Check Failure #2 help

This is a discussion on Run-Time Check Failure #2 help within the C Programming forums, part of the General Programming Boards category; for some reason my variable 'character' is causing this message to pop up. - Run-Time Check Failure #2 - Stack ...

  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,672
    Code:
    scanf_s( "%C", &character);
    Format specifiers are case sensitive, that should be %c, not %C.
    I used to be an adventurer like you... then I took an arrow to the knee.

  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, 11:15 AM
  3. Replies: 7
    Last Post: 11-26-2007, 12:11 PM
  4. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 06: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

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