Thread: Newbie Question

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    Is this post invisible or what
    http://cboard.cprogramming.com/showthread.php?t=25765

    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.

  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, 06:45 PM
  3. a stupid question from a newbie
    By newcomer in forum C++ Programming
    Replies: 4
    Last Post: 01-11-2003, 04:38 PM
  4. confusion with integers (newbie question)
    By imortal in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 04:09 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM