头文件将不是在C工作 [英] Header files won't work in C

查看:115
本文介绍了头文件将不是在C工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的开发,CPP,(但在C编程),和头文件将无法正常工作。我去了编译器选项;目录; çinludes并检查该目录是正确的,它是。包含文件保存在C:\\开发的cpp \\包括而这也正是它被设置为接收它们。

I'm using Dev-CPP, (but programming in C), and the header files won't work. I've gone to compiler option; directories; c inludes and checked the directory is correct, and it is. The include files are stored in C:\Dev-Cpp\include and that's where it's set to receive them.

例如:

#include <conio.h>

int main(int argc, char *argv[])
{
  textcolor(1);

  printf("Why won't header files work? \n");

  system("PAUSE");  
  return 0;
}

我试过与其他几个头文件,但他们也不起作用。我相信答案是真的很明显,但我很清楚的太傻来解决这个问题。我还使用MinGW的作为编译器(带有DEV-CPP标准)。请帮帮我。

I've tried with several other header files, but they also don't work. I'm sure the answer is really obvious, but I'm clearly too stupid to fix this. I'm also using MinGW as the compiler, (comes standard with dev-cpp). Please help me.

推荐答案

文本颜色()很老了。(也许用Borland C ++?)

textcolor() very old.(Perhaps borland c++ ?)

例如。重新定义这样

#include <Windows.h>
#include <stdio.h>
#include <conio.h>

void textcolor(unsigned short color){
    HANDLE hStdout;
    WORD wAttributes;
    CONSOLE_SCREEN_BUFFER_INFO csbi;

    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

    GetConsoleScreenBufferInfo(hStdout, &csbi);

    wAttributes = color ;
    if (color & 0x08) wAttributes |= FOREGROUND_INTENSITY ;

    SetConsoleTextAttribute(hStdout, wAttributes);
}

/*
#define FOREGROUND_BLUE      0x0001
#define FOREGROUND_GREEN     0x0002
#define FOREGROUND_RED       0x0004
#define FOREGROUND_INTENSITY 0x0008

#define BACKGROUND_BLUE      0x0010
#define BACKGROUND_GREEN     0x0020
#define BACKGROUND_RED       0x0040
#define BACKGROUND_INTENSITY 0x0080
*/

int main(int argc, char *argv[]){
    textcolor(1);
//  textcolor(FOREGROUND_BLUE);
    printf("FOREGROUND_BLUE \n");

    textcolor(4);
    printf("FOREGROUND_RED \n");

    textcolor(7);
    system("PAUSE");  
    return 0;
}

这篇关于头文件将不是在C工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆