What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » WLM Plus! Help » Plugin Help C++ opening file

Plugin Help C++ opening file
Author: Message:
crank
Full Member
***

Avatar
Failed to come back here :(

Posts: 304
Reputation: 17
35 / Male / Flag
Joined: Mar 2004
Status: Away
O.P. Huh?  Plugin Help C++ opening file
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)

This post was edited on 08-12-2004 at 02:11 PM by crank.
I haven't been active here in ages.
If you're wondering who i am, read my reputations. I used to make plugins, skins and spam the IRC channels here back in the good old days before Windows Live.
08-12-2004 02:02 PM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Plugin Help C++ opening file
code:
if(nRandom == 0) {
    ifstream b_file("QTS1.txt");
    b_file>>str;
    strcpy(sResult, str);
    b_file.close();
}
Same code, with added bracyness. That should clear a lot of the errors you're having, if not all.
[Image: spartaafk.png]
08-13-2004 09:51 AM
Profile PM Web Find Quote Report
crank
Full Member
***

Avatar
Failed to come back here :(

Posts: 304
Reputation: 17
35 / Male / Flag
Joined: Mar 2004
Status: Away
O.P. RE: Plugin Help C++ opening file
I'll try that

EDIT:Woohooow woohooow SUPER[Image: bozo.png]!!!!
It worked

EDIT2:

The only thing wrong is that the thing ouputs Ì 1100 times instead of the text in the file.


This post was edited on 08-13-2004 at 05:34 PM by crank.
I haven't been active here in ages.
If you're wondering who i am, read my reputations. I used to make plugins, skins and spam the IRC channels here back in the good old days before Windows Live.
08-13-2004 05:23 PM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Plugin Help C++ opening file
str is a char variable? If so, that's why. You'll have to write code that can read whole strings instead.
I recommend you get a book on C++: it will tell you all you need to know. I recommend Sam's Teach Yourself C++ in 21 Days.
[Image: spartaafk.png]
08-13-2004 06:53 PM
Profile PM Web Find Quote Report
crank
Full Member
***

Avatar
Failed to come back here :(

Posts: 304
Reputation: 17
35 / Male / Flag
Joined: Mar 2004
Status: Away
O.P. RE: Plugin Help C++ opening file
I'm looking for a book on C++ but It has to be dutch...
I haven't been active here in ages.
If you're wondering who i am, read my reputations. I used to make plugins, skins and spam the IRC channels here back in the good old days before Windows Live.
08-17-2004 01:35 PM
Profile E-Mail PM Web Find Quote Report
Tochjo
forum super mod
******

Avatar

Posts: 4207
Reputation: 78
37 / Male / Flag
Joined: Sep 2003
Status: Online
RE: Plugin Help C++ opening file
quote:
Originally posted by çr@nK
I'm looking for a book on C++ but It has to be dutch...
Bol.com > Netherlands > Boeken (Nederlands)/Books (Dutch): C++

This post was edited on 08-17-2004 at 01:40 PM by Tochjo.
08-17-2004 01:40 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On