想写一个程序,从文本文件中读入数据,处理以后在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编程中的文件操作