首页 > 解决方案 > 如何在c中为不同的功能设置不同的颜色

问题描述

我想为 main 和 add 功能设置两种不同的颜色。但是这样,当执行 add 函数时,整个输出文本颜色变成红色。

#include<stdio.h>
#include<windows.h>

int add(a,b){
    system("Color 4");
    printf("the sum of two numbers %d",a+b);

}

int main(){
    int a,b;
    system("Color A");
    printf("\nEnter two numbers\n");
    scanf("%d %d",&a,&b);
    add(a,b);
    return 0;

}

标签: cwindows

解决方案


推荐阅读