Thread: I've made simple code the plus calulation but it doesn't work.

  1. #1
    Registered User
    Join Date
    Oct 2015
    Posts
    3

    I've made simple code the plus calulation but it doesn't work.

    Code:
    #include <stdio.h>
    void print_help(void)
    {
     printf("\n\n");
     printf("\n******************************");
     printf("\n*         덧셈프로그램       *");
     printf("\n*                            *");
     printf("\n*                만든이 : YB *");
     printf("\n                             *");
     printf("\n******************************");
    }
    int process(int a, int b)
    {
     int sub = 0;
     sub = a + b;
     return sub;
    }
    void print_sum(int sum)
    {
     printf("\n 두 수의 합은 %d입니다.", sum);
    }
    int main()
    {
     int num1 = 0, num2 = 0, sum;
     print_help();
     printf("\n 첫번째 수를 입력하세요 : ");
     scanf_s("%d", num1);
     printf("\n 두번째 수를 입력하세요 : ");
     scanf_s("%d", num2);
     sum = process(num1, num2);
     print_sum(sum);
     return 0;
    }
    I've made the plus caluation as above code but it doesn't work....

    when I try the code build I got this error as below screenshot.

    I've made simple code the plus calulation but it doesn't work.-1111-jpg

    Can someone help me out from this error?

    Thank you
    YB.Shin

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    scanf expects a pointer, you give it an integer. You need to use the "&" operator in front of a variable to get its pointer.
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Oct 2015
    Posts
    3
    Hi

    It works well.

    Thank you so much.

  4. #4
    Registered User
    Join Date
    Oct 2015
    Posts
    3
    Quote Originally Posted by GReaper View Post
    scanf expects a pointer, you give it an integer. You need to use the "&" operator in front of a variable to get its pointer.
    Hi http://im.cprogramming.com/images/smilies/smile.png

    It works well.

    Thank you so much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I made a program but it doesn't work correctly
    By jeremy duncan in forum C Programming
    Replies: 30
    Last Post: 11-01-2011, 01:57 PM
  2. Replies: 9
    Last Post: 09-09-2007, 08:08 AM
  3. Simple C++ code doesn't work
    By alex_dude_122 in forum C++ Programming
    Replies: 6
    Last Post: 10-18-2006, 12:53 PM
  4. simple fread doesn't work
    By ronenk in forum C Programming
    Replies: 3
    Last Post: 10-15-2004, 05:08 AM
  5. Why doesn't this work? (simple)
    By Clyde in forum C Programming
    Replies: 3
    Last Post: 04-02-2002, 04:48 PM