| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3777 人关注过本帖, 6 人收藏
标题:Windows 控制台下的绘图方法
只看楼主 加入收藏
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
你用的什么编译器?这是Windows下使用Win API的程序,不要在别的环境中编译。

授人以渔,不授人以鱼。
2012-04-05 18:30
michaelc
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2012-4-5
收藏
得分:0 
:\Text1.c(7) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(7) : error C2143: syntax error : missing '{' before 'constant'
F:\Text1.c(7) : error C2059: syntax error : '<Unknown>'
F:\Text1.c(8) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(8) : error C2143: syntax error : missing '{' before 'constant'
F:\Text1.c(8) : error C2059: syntax error : '<Unknown>'
F:\Text1.c(8) : error C2059: syntax error : ')'
F:\Text1.c(11) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(11) : error C2143: syntax error : missing '{' before 'constant'
F:\Text1.c(11) : error C2059: syntax error : '<Unknown>'
F:\Text1.c(11) : error C2059: syntax error : ')'
F:\Text1.c(12) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(12) : error C2143: syntax error : missing '{' before 'constant'
F:\Text1.c(12) : error C2059: syntax error : '<Unknown>'
F:\Text1.c(12) : error C2059: syntax error : ')'
F:\Text1.c(14) : error C2143: syntax error : missing ')' before '('
F:\Text1.c(14) : error C2143: syntax error : missing ')' before '('
F:\Text1.c(14) : error C2091: function returns function
F:\Text1.c(14) : error C2091: function returns function
F:\Text1.c(14) : error C2059: syntax error : ')'
F:\Text1.c(14) : error C2059: syntax error : ')'
F:\Text1.c(29) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(29) : warning C4024: 'ReleaseDC' : different types for formal and actual parameter 2
F:\Text1.c(34) : error C2143: syntax error : missing ')' before '('
F:\Text1.c(34) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(34) : error C2091: function returns function
F:\Text1.c(34) : error C2143: syntax error : missing ';' before 'constant'
F:\Text1.c(34) : error C2059: syntax error : ')'
F:\Text1.c(34) : error C2059: syntax error : ')'
F:\Text1.c(35) : error C2275: 'HBRUSH' : illegal use of this type as an expression
        d:\microsoft visual studio\vc98\include\windef.h(233) : see declaration of 'HBRUSH'
F:\Text1.c(35) : error C2146: syntax error : missing ';' before identifier 'hBrush'
F:\Text1.c(35) : warning C4013: 'hBrush' undefined; assuming extern returning int
F:\Text1.c(36) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(36) : warning C4024: 'SelectObject' : different types for formal and actual parameter 1
F:\Text1.c(37) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(37) : warning C4024: 'SelectObject' : different types for formal and actual parameter 1
F:\Text1.c(38) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(38) : warning C4024: 'Rectangle' : different types for formal and actual parameter 1
F:\Text1.c(45) : error C2143: syntax error : missing ')' before '('
F:\Text1.c(45) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(45) : error C2091: function returns function
F:\Text1.c(45) : error C2143: syntax error : missing ';' before 'constant'
F:\Text1.c(45) : error C2059: syntax error : ')'
F:\Text1.c(45) : error C2059: syntax error : ')'
F:\Text1.c(46) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(46) : warning C4024: 'SelectObject' : different types for formal and actual parameter 1
F:\Text1.c(47) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(47) : warning C4024: 'MoveToEx' : different types for formal and actual parameter 1
F:\Text1.c(48) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(48) : warning C4024: 'LineTo' : different types for formal and actual parameter 1
F:\Text1.c(54) : error C2143: syntax error : missing ')' before '('
F:\Text1.c(54) : error C2143: syntax error : missing ')' before 'constant'
F:\Text1.c(54) : error C2091: function returns function
F:\Text1.c(54) : error C2143: syntax error : missing ';' before 'constant'
F:\Text1.c(54) : error C2059: syntax error : ')'
F:\Text1.c(54) : error C2059: syntax error : ')'
F:\Text1.c(55) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(55) : warning C4024: 'SelectObject' : different types for formal and actual parameter 1
F:\Text1.c(56) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(56) : warning C4024: 'MoveToEx' : different types for formal and actual parameter 1
F:\Text1.c(57) : error C2143: syntax error : missing ';' before 'type'
F:\Text1.c(57) : error C2143: syntax error : missing ';' before 'type'
F:\Text1.c(57) : error C2143: syntax error : missing ')' before 'type'
F:\Text1.c(57) : error C2143: syntax error : missing ';' before 'type'
F:\Text1.c(57) : error C2065: 'x' : undeclared identifier
F:\Text1.c(57) : error C2065: 'PI' : undeclared identifier
F:\Text1.c(57) : warning C4552: '<=' : operator has no effect; expected operator with side-effect
F:\Text1.c(57) : error C2059: syntax error : ')'
F:\Text1.c(58) : error C2065: 'Increase' : undeclared identifier
F:\Text1.c(58) : error C2143: syntax error : missing ';' before '{'
F:\Text1.c(59) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(59) : warning C4024: 'LineTo' : different types for formal and actual parameter 1
F:\Text1.c(59) : error C2065: 'static_cast' : undeclared identifier
F:\Text1.c(59) : error C2059: syntax error : 'type'
F:\Text1.c(68) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(68) : warning C4024: 'SetTextColor' : different types for formal and actual parameter 1
F:\Text1.c(69) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(69) : warning C4024: 'SetBkColor' : different types for formal and actual parameter 1
F:\Text1.c(70) : warning C4047: 'function' : 'struct HDC__ *' differs in levels of indirection from 'struct HDC__ *(__cdecl *(__cdecl *(__cdecl *)())())()'
F:\Text1.c(70) : warning C4024: 'DrawTextW' : different types for formal and actual parameter 1
F:\Text1.c(70) : warning C4013: '_countof' undefined; assuming extern returning int
F:\Text1.c(72) : error C2275: 'HANDLE' : illegal use of this type as an expression
        d:\microsoft visual studio\vc98\include\winnt.h(207) : see declaration of 'HANDLE'
F:\Text1.c(72) : error C2146: syntax error : missing ';' before identifier 'hConsole'
F:\Text1.c(72) : warning C4013: 'hConsole' undefined; assuming extern returning int
F:\Text1.c(73) : error C2275: 'CONSOLE_CURSOR_INFO' : illegal use of this type as an expression
        d:\microsoft visual studio\vc98\include\wincon.h(174) : see declaration of 'CONSOLE_CURSOR_INFO'
F:\Text1.c(73) : error C2146: syntax error : missing ';' before identifier 'CursorInfo'
F:\Text1.c(73) : error C2065: 'CursorInfo' : undeclared identifier
F:\Text1.c(74) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _CONSOLE_CURSOR_INFO *'
F:\Text1.c(75) : error C2224: left of '.bVisible' must have struct/union type
F:\Text1.c(75) : error C2065: 'false' : undeclared identifier
F:\Text1.c(76) : warning C4133: 'function' : incompatible types - from 'int *' to 'const struct _CONSOLE_CURSOR_INFO *'
F:\Text1.c(77) : warning C4013: '_getwch' undefined; assuming extern returning int
F:\Text1.c(77) : error C2065: 'K_ENTER' : undeclared identifier
F:\Text1.c(81) : error C2224: left of '.bVisible' must have struct/union type
F:\Text1.c(81) : error C2065: 'true' : undeclared identifier
F:\Text1.c(82) : warning C4133: 'function' : incompatible types - from 'int *' to 'const struct _CONSOLE_CURSOR_INFO *'
Error executing cl.exe.

Text1.obj - 62 error(s), 34 warning(s)
为什么我是这样的?
2012-04-05 21:47
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
好些天没来了 帮顶!

梅尚程荀
马谭杨奚







                                                       
2012-04-05 22:02
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
回复 22楼 michaelc
这是C++程序,文件扩展名为.cpp,不是.c。

授人以渔,不授人以鱼。
2012-04-05 22:10
michaelc
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2012-4-5
收藏
得分:0 
回复 24楼 TonyDeng
谢谢,但是拓展名改了之后还是会出现错误,如下:
Compiling...
Text1.cpp
C:\Documents and Settings\Administrator\桌面\Text1.cpp(14) : error C2065: 'GetConsoleWindow' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\Text1.cpp(70) : error C2065: '_countof' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\Text1.cpp(77) : error C2065: '_getwch' : undeclared identifier
Error executing cl.exe.

Text1.obj - 3 error(s), 0 warning(s)
求指教。
2012-04-06 08:09
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
缺了Windows.h头。
第1个(取cmd窗口的句柄)是Windows API的库函数,用Windows.h,这个程序绝大多数的函数都是这个头中的函数
第2个(统计数组的元素数目)是在stdlib.h头中的,Windows.h自动包含它,如果没有,就自己#include <stdlib.h>
第3个(从键盘接收一个按键,其值是4字节的整数,即宽字符版本_getch(),对应K_ENTER的值即知)是在conio.h头中的,用于控制台键盘和屏幕IO


[ 本帖最后由 TonyDeng 于 2012-4-6 11:55 编辑 ]

授人以渔,不授人以鱼。
2012-04-06 11:14
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
小声一下,这里用vc6的人还是比较多,T版的程序能否照顾一下这些人呢?

我们都在路上。。。。。
2012-04-06 15:40
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
以下是引用hellovfp在2012-4-6 15:40:30的发言:

小声一下,这里用vc6的人还是比较多,T版的程序能否照顾一下这些人呢?

我没用过VC6,不知道哪些函数它没有。

授人以渔,不授人以鱼。
2012-04-06 20:31
hedaacm
Rank: 6Rank: 6
来 自:河北保定
等 级:侠之大者
威 望:2
帖 子:400
专家分:418
注 册:2012-1-26
收藏
得分:0 
如果C++也有  tuboc的<graphics.h>就好了  这样交作业很容易   爱╮(╯▽╰)╭
2012-11-17 19:04
我爱编程11
Rank: 2
等 级:论坛游民
帖 子:36
专家分:21
注 册:2017-12-17
收藏
得分:0 
可以把控制台的代码好好解析一下吗?方便我们学习
2018-01-02 19:43
快速回复:Windows 控制台下的绘图方法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017258 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved