Thread: short matrix problem

  1. #76
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I don't suppose you've read the manual page for scanf in all your fumbling around.

    man page scanf section 3
    RETURN VALUES

    These functions return the number of input items assigned. This can be
    fewer than provided for, or even zero, in the event of a matching fail-
    ure. Zero indicates that, although there was input available, no conver-
    sions were assigned; typically this is due to an invalid input character,
    such as an alphabetic character for a `%d' conversion. The value EOF is
    returned if an input failure occurs before any conversion such as an end-
    of-file occurs. If an error or end-of-file occurs after conversion has
    begun, the number of conversions which were successfully completed is
    returned.
    So, begin with
    int result = scanf("%d",&matrix[c][d]);
    printf("scanf returned %d\n", result );

    And observe what you get when you
    - type in a number
    - type in a letter
    - type in your platform specific key sequence (ctrl-d or ctrl-z) to signal EOF
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #77
    Registered User
    Join Date
    May 2012
    Posts
    210
    I just wanted to say thank you to everyone here
    i finished my project and honestly i would've bin lost without u guys
    thank you for taking out the time to help me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-01-2012, 10:57 PM
  2. How come short + int = int but short + uint = long?
    By y99q in forum C# Programming
    Replies: 2
    Last Post: 10-29-2011, 11:16 AM
  3. Please help! short while loop tracking problem.
    By matthayzon89 in forum C Programming
    Replies: 7
    Last Post: 04-22-2010, 12:29 PM
  4. Replies: 2
    Last Post: 04-21-2008, 07:43 PM
  5. Replies: 7
    Last Post: 02-08-2008, 06:31 PM