| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1654 人关注过本帖
标题:请问关于windows编程中的文件操作
只看楼主 加入收藏
挑灯看剑
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-4-14
收藏
 问题点数:0 回复次数:5 
请问关于windows编程中的文件操作

想写一个程序,从文本文件中读入数据,处理以后在windows窗口中图形显示出来。
文件读入用的是c++中的文件流ifstream,这部分单独在vc6中编译通过并可以运行;
windows窗口是《windows程序设计》的代码改编过来的,单独也能运行。

但两部分合在一起时出错了。各位大侠帮我看看,谢谢~
部分代码:


//windows程序中的头文件部分
#include <windows.h>
#include <math.h>

//c++文件操作的头文件部分

#include <iostream.h>
#include <string.h>
#include <fstream.h>

//声明文件流变量
ifstream if1("i.txt");
ofstream of1("o.txt");



错误提示:
--------------------Configuration: Clock - Win32 Debug--------------------
Compiling...
Clock.c
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(33) : error C2065: 'ifstream' : undeclared identifier
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(33) : error C2146: syntax error : missing ';' before identifier 'if1'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(33) : warning C4013: 'if1' undefined; assuming extern returning int
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(34) : error C2065: 'ofstream' : undeclared identifier
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(34) : error C2146: syntax error : missing ';' before identifier 'of1'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(34) : warning C4013: 'of1' undefined; assuming extern returning int
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(36) : error C2143: syntax error : missing ';' before 'type'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(37) : error C2143: syntax error : missing ';' before 'type'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(40) : error C2224: left of '.getline' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(40) : error C2065: 'c1' : undeclared identifier
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(42) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2065: 'c' : undeclared identifier
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2066: cast to function type is illegal
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(43) : error C2143: syntax error : missing ';' before '>='
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(44) : error C2224: left of '.putback' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(45) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(46) : error C2296: '<<' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(61) : error C2224: left of '.getline' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(62) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(62) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(62) : error C2066: cast to function type is illegal
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(62) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(62) : error C2143: syntax error : missing ';' before '>='
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(63) : error C2224: left of '.putback' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(64) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(70) : error C2065: 'cout' : undeclared identifier
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(70) : error C2297: '<<' : illegal, right operand has type 'char [3]'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(73) : error C2146: syntax error : missing ';' before identifier 'if2'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(73) : warning C4013: 'if2' undefined; assuming extern returning int
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(75) : error C2224: left of '.getline' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(80) : error C2224: left of '.getline' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(83) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(85) : error C2296: '<<' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(87) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(87) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(87) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(94) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(94) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(94) : error C2066: cast to function type is illegal
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(94) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(94) : error C2143: syntax error : missing ';' before '>='
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(95) : error C2224: left of '.putback' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(96) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(98) : error C2224: left of '.getline' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(101) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(103) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(103) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(103) : error C2109: subscript requires array or pointer type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(106) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(106) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(106) : error C2066: cast to function type is illegal
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(106) : error C2146: syntax error : missing ')' before identifier 'c'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(106) : error C2143: syntax error : missing ';' before '>='
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(107) : error C2224: left of '.putback' must have struct/union type
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(108) : error C2296: '>>' : illegal, left operand has type 'int (__cdecl *)()'
D:\动画\windows程序设计的源码\284426099\Chap08\Chap08\Clock\Clock.c(109) : error C2297: '<<' : illegal, right operand has type 'char [4]'
执行 cl.exe 时出错.

搜索更多相关主题的帖子: windows 文件操作 include 图形 math 
2007-04-14 21:45
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 
头文件是否有放错位置了.

=×&D o I p R e E n C g T l X&×=
2007-04-15 09:19
挑灯看剑
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-4-14
收藏
得分:0 

能否详细解释一下?
本来两个程序单独可以运行的,合在一起的时候出错了

2007-04-15 10:18
挑灯看剑
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-4-14
收藏
得分:0 

犯错误了……
《windows程序设计》中的代码是.c文件,改成.cpp文件后错误变成:
是不是不能在vc中用windows编程呢?

--------------------Configuration: Clock - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Clock.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

Clock.exe - 1 error(s), 0 warning(s)

2007-04-15 10:32
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 
工程的错误.
要用Win32 Application, 你用的是Win32 Console Application.

=×&D o I p R e E n C g T l X&×=
2007-04-15 15:29
挑灯看剑
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-4-14
收藏
得分:0 
Thank you very much!
2007-04-15 18:17
快速回复:请问关于windows编程中的文件操作
数据加载中...
 
   



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

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