Thread: scanf statement prob

  1. #1
    Registered User
    Join Date
    Jun 2010

    Smile scanf statement prob

    i came across this code in C++ the complete reference by herb schildt,
    specifically in the tic-tac toe example:
    void get_player_move(void)
    int x, y;
    printf("Enter X,Y coordinates for your move: ");
    scanf("%d%*c%d", &x, &y);
    x--; y--;
    if(matrix[x][y]!= ' '){
    printf("Invalid move, try again.\n");
    else matrix[x][y] = 'X';
    My problem is in the scanf statement. what is the purpose of *c?
    when i remove *c and execute the prog. vista shows the message tic-tac-toe.exe has stopped working.
    what am i doing wrong ?
    i am using vista and visual C++2008 Express.
    kindly spare your time to answer this, and sorry if this has been asked before but i couldn't find the solution.

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Its used to skip data -> scanf - C++ Reference

    Use Code Tags
    Spidey out!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Random guessing game
    By Nalif in forum C Programming
    Replies: 16
    Last Post: 10-26-2006, 03:05 AM
  2. Meaning of this statement?
    By @nthony in forum C Programming
    Replies: 7
    Last Post: 07-16-2006, 02:57 AM
  3. compile prob
    By chizzy in forum C Programming
    Replies: 6
    Last Post: 10-05-2003, 12:26 AM
  4. help with switch statements
    By Wexy in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 05:44 PM
  5. scanf - data is "put back" - screws up next scanf
    By voltson in forum C Programming
    Replies: 10
    Last Post: 10-14-2002, 04:34 AM