C言語でよくあるエラーのまとめ

  1. 「 ; 」がありません [および英字です]
  2. 大きな構造エラー:
#include <stdio.h>

int main()
{
    
    
	return 0;
}
  1. エラー: [エラー] '{' トークンの前に修飾されていない ID が必要です
    [エラー コード]
#include <stdio.h>
{
    
                      
    int main()         //错误代码
	int a,b,c;         
	return 0;
}

【正しいコード】

#include <stdio.h>

int main()             //正确代码 将  int main()  放置首行代码下面 
{
    
    
	int a,b,c;
	return 0;
}
  1. ユーザー入力後に
    [エラーコード]を読み取ることができませんでした
#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;
}

【正しいコード】

#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;
}

おすすめ

転載: blog.csdn.net/m0_57495651/article/details/132251197