Newbie Question

This is a discussion on Newbie Question within the C Programming forums, part of the General Programming Boards category; I am starting to learn how to program in C and i came across and sample script and it doesn't ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    5

    Question Newbie Question

    I am starting to learn how to program in C and i came across and sample script and it doesn't seem to be working, here is the sample script:

    #include <stdio.h>

    int main(void){

    int a, b;
    printf("Enter two numbers: ");
    scanf("%1 %1", &a, &b);

    printf("%1 - %1 = %1\n", a, b, a - b);

    return 0;

    }


    I am able to compile it fine, but when i run it and enter two numbers instead of it doing the calculation and printing it out it just prints out:
    %1 - %1 = %1


    Can anyone tell me why it is doing that or how to fix it. Thank you in advance.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Is this post invisible or what
    << !! Posting Code? Read this First !! >>

    They're called programs, not scripts.

    And all those 1's should be lower-case i
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    5
    Cool, it works. Thnx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 05:45 PM
  3. a stupid question from a newbie
    By newcomer in forum C++ Programming
    Replies: 4
    Last Post: 01-11-2003, 03:38 PM
  4. confusion with integers (newbie question)
    By imortal in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 03:09 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM

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