鱼C论坛

 找回密码
 立即注册
查看: 3818|回复: 2

关于Visual c++ 6.0的小疑问,求助!!!

[复制链接]
发表于 2014-2-19 18:29:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. //talkback.c--一个能为你提供一切信息的对话程序。
  2. #include <stdio.h>
  3. #include <string>
  4. #define DENSITY

  5. int main(void)
  6. {
  7. float weight, volume;
  8. int size, letters;
  9. char name[40];

  10. printf("HI What's your first name: \n");
  11. scanf("%s", &name);
  12. printf("%s, what's you weight in pounds: \n", name);
  13. scanf("%f", &weight);
  14. size = sizeof name;
  15. letters = strlen(name);
  16. volume = weight/DENSITY;
  17. printf("well, %s, your volume is %2.2f cubic feet.\n", name, volume);
  18. printf("Also, your first name has %d letter,\n", letters);
  19. printf("and we have %d bytes to store it in.\n", size);
  20. return (0);
  21. }
复制代码
代码如上,自觉没有任何问题,但是编译之后,出现了一个error:
c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error :  "eh.h is only for C++!"
此时选中这个error之后,突然所有的源代码都变了。
  1. /***
  2. *eh.h - User include file for exception handling.
  3. *
  4. * Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * User include file for exception handling.
  8. *
  9. * [Public]
  10. *
  11. ****/

  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif

  15. #ifndef _INC_EH
  16. #define _INC_EH

  17. #if !defined(_WIN32) && !defined(_MAC)
  18. #error ERROR: Only Mac or Win32 targets supported!
  19. #endif


  20. #ifdef _MSC_VER
  21. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  22. // alignment.
  23. #pragma pack(push,8)
  24. #endif // _MSC_VER

  25. #ifndef __cplusplus
  26. #error "eh.h is only for C++!"
  27. #endif


  28. /* Define _CRTIMP */

  29. #ifndef _CRTIMP
  30. #ifdef _DLL
  31. #define _CRTIMP __declspec(dllimport)
  32. #else /* ndef _DLL */
  33. #define _CRTIMP
  34. #endif /* _DLL */
  35. #endif /* _CRTIMP */

  36. /* Define _CRTAPI1 (for compatibility with the NT SDK) */

  37. #ifndef _CRTAPI1
  38. #if _MSC_VER >= 800 && _M_IX86 >= 300
  39. #define _CRTAPI1 __cdecl
  40. #else
  41. #define _CRTAPI1
  42. #endif
  43. #endif

  44. typedef void (__cdecl *terminate_function)();
  45. typedef void (__cdecl *unexpected_function)();
  46. typedef void (__cdecl *terminate_handler)();
  47. typedef void (__cdecl *unexpected_handler)();

  48. #ifndef _MAC
  49. struct _EXCEPTION_POINTERS;
  50. typedef void (__cdecl *_se_translator_function)(unsigned int, struct _EXCEPTION_POINTERS*);
  51. #endif

  52. #if _MSC_VER >= 1200
  53. _CRTIMP __declspec(noreturn) void __cdecl terminate(void);
  54. _CRTIMP __declspec(noreturn) void __cdecl unexpected(void);
  55. #else
  56. _CRTIMP void __cdecl terminate(void);
  57. _CRTIMP void __cdecl unexpected(void);
  58. #endif

  59. _CRTIMP terminate_function __cdecl set_terminate(terminate_function);
  60. _CRTIMP unexpected_function __cdecl set_unexpected(unexpected_function);
  61. #ifndef _MAC
  62. _CRTIMP _se_translator_function __cdecl _set_se_translator(_se_translator_function);
  63. #endif

  64. #ifdef _MSC_VER
  65. #pragma pack(pop)
  66. #endif // _MSC_VER

  67. #endif // _INC_EH
复制代码

我都不认识了,这到底是怎么回事?求大神解答啊,上网百度了一下那个error,说是什么不是c++文件,但我确实是按照小甲鱼教的方式创建的啊,怎么突然就出现问题了呢,郁闷,跪求答案啊~~~~~~~~
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-2-20 01:55:33 | 显示全部楼层
#define DENSITY
问题出在这里,这里后面要有值好比#define DENSITY 1
这样就行了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-2-20 08:47:34 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-13 07:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表