I'm working at QTSender during my spare time(when i'm not fixing MSNBrowser).
I found a code for a file but I can't make it really work.
Headers:
code:
#include <fstream.h>
#include <iostream.h>
Code:
code:
char str[1100]; //set string lenght
int nRandom = rand()%3;
if(nRandom == 0)
ifstream b_file("QTS1.txt");//opens file for reading
b_file>>str; //reads one string from file
strcpy(sResult, str); //output text
b_file.close();//close file
Build/Debug Log:
code:
MPPluginC.cpp
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(96) : error C2065: 'b_file' : undeclared identifier
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(96) : error C2297: '>>' : illegal, right operand has type 'char [1100]'
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(98) : error C2228: left of '.close' must have class/struct/union type
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(102) : error C2297: '>>' : illegal, right operand has type 'char [1100]'
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(104) : error C2228: left of '.close' must have class/struct/union type
c:\documents and settings\kenneth\mijn documenten\msgplus!plugin source\qts(openfiletest)\vc\mppluginc\mppluginc.cpp(106) : error C2181: illegal else without matching if
Error executing cl.exe.
MPPluginC.obj - 6 error(s), 0 warning(s)
(If you copy this to notepad it will be easier to read)
My question is how to fix those errors???
Or is the code to open the file wrong???
What should i change the >> too???
I know most of these are 'beginner' faults but i just can't work with files in C++
Fixed some stuff myself (the
bold stuff)