A record of mistakes made in the programming of C language Program (i)

Source: Internet
Author: User

Today's study uses the program of "C Program Design (fourth edition)" To find the maximum value of two numbers.
Devcpp Program:
#include <stdio.h>
int main ()
{
int max (int x,int y);
int a,b,c;
scanf ("%d,%d", &a,&b);
C=max (A, b);
printf ("max=%d\n", c);
System ("pause");
return 0;
}
int max (int x,int y)
{
int z;
if (x<y) z=y;
else z=x;
printf ("%d\n", z);
return (z);
}

VS2017 Program:
#include <stdio.h>
int main ()
{
int max (int x,int y);
int a,b,c;
scanf_s ("%d,%d", &a,&b);
C=max (A, b);
printf ("max=%d\n", c);
System ("pause");
return 0;
}
int max (int x,int y)
{
int z;
if (x<y) z=y;
else z=x;
printf ("%d\n", z);
return (z);
}

' scanf ': This function/variable may be unsafe, consider using scanf_s to replace it. If you want to ignore this warning, use the macro _crt_secure_no_warnings
Referenced from "http://bbs.csdn.net/topics/390508208?page=1"

Error encountered:
1, Chinese and English characters problem: The Input method is the default language, in the editing interface for the English, but run the popup automatically switch back to Chinese, enter a comma between two numbers is Chinese, resulting in a program run error.
2, in the test, in order to eliminate the problem using scanf ("%d,%d", &a,&b), when the variable before forgetting to add &, causing the program to run an error.

A record of mistakes made in the programming of C language Program (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.