Summary of common errors in C language

  1. Missing " ; " [and is an English character]
  2. Large structure error:
#include <stdio.h>

int main()
{
    
    
	return 0;
}
  1. Error: [Error] expected unqualified-id before '{' token
    [Error code]
#include <stdio.h>
{
    
                      
    int main()         //错误代码
	int a,b,c;         
	return 0;
}

【Correct code】

#include <stdio.h>

int main()             //正确代码 将  int main()  放置首行代码下面 
{
    
    
	int a,b,c;
	return 0;
}

  1. Failed to read [error code] after user input
#include <stdio.h>
  int main()
{
    
    

	
	int a,b,c;
	
	scanf("%d %d %d" ,a,b,c); // 错误代码,缺少“ & "
	
	int max=0;
	
	if(a>b)
	{
    
    
		if(a>c)
		{
    
    
			max=a;
		}
		else// a<c
		{
    
    
			max=c;
		}
	}
	else// a<b
	{
    
    
		if(b>c)
		{
    
    
			max=b;
		}
		else// b<c
		{
    
    
			max=c;
		}
	}
	
	printf("This is the max number:%d\n",max);
	
	
	return 0;
}

【Correct code】

#include <stdio.h>
  int main()
{
    
    

	
	int a,b,c;
	
	scanf("%d %d %d" ,&a,&b,&c); // 正确代码,添加“ & "
	
	int max=0;
	
	if(a>b)
	{
    
    
		if(a>c)
		{
    
    
			max=a;
		}
		else// a<c
		{
    
    
			max=c;
		}
	}
	else// a<b
	{
    
    
		if(b>c)
		{
    
    
			max=b;
		}
		else// b<c
		{
    
    
			max=c;
		}
	}
	
	printf("this is the max number:%d\n",max);
	
	
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_57495651/article/details/132251197