Hi coders, I need your help for a program that I'm doing!
I need to parse a text file, so I open it, read it and put the text in a buffer: - int len;
-
char *buff;
-
-
ifstream is;
-
is.open ("text.txt", ios::binary );
-
-
is.seekg (0, ios::end);
-
len= is.tellg();
-
is.seekg (0, ios::beg);
-
-
buffer = new char [len];
-
-
is.read (buff,len);
Now I found this code: - istreambuf_iterator<char> bit(cin), eit; // get stdin iterators
-
Parsing test(bit, eit); // parse and load the text
-
printFile(&test); // print the text structure
and here my questions:
1) istreambuf_iterator<char> bit(cin), eit; ------> "cin" is the "keyboard" input??
2) how can I modify this code to use the content of the file instead of the "keyboard" input?
9 2056
Hi coders, I need your help for a program that I'm doing!
I need to parse a text file, so I open it, read it and put the text in a buffer: - int len;
-
char *buff;
-
-
ifstream is;
-
is.open ("text.txt", ios::binary );
-
-
is.seekg (0, ios::end);
-
len= is.tellg();
-
is.seekg (0, ios::beg);
-
-
buffer = new char [len];
-
-
is.read (buff,len);
Now I found this code: - istreambuf_iterator<char> bit(cin), eit; // get stdin iterators
-
Parsing test(bit, eit); // parse and load the text
-
printFile(&test); // print the text structure
and here my questions:
1) istreambuf_iterator<char> bit(cin), eit; ------> "cin" is the "keyboard" input??
2) how can I modify this code to use the content of the file instead of the "keyboard" input?
1) Yep, cin is an istream attached to the standard input (the keyboard usually).
2) replace 'cin' by your 'is'. 'is' is also a proper istream.
kind regards,
Jos
1) Yep, cin is an istream attached to the standard input (the keyboard usually).
2) replace 'cin' by your 'is'. 'is' is also a proper istream.
kind regards,
Jos
Thank you for the quick answer, as I thought I have to replace 'cin' with 'is'.
Unfortunatelly I think that the function that has to print the content of the file doesn't work and I have no idea how to fix it!
Is anyone able to tell me quite specifically what this code does??
Any help is appreciated!! - void printMimeStructure(MimeEntity* pMe, int tabcount = 0)
-
{
-
Header& h = pMe->header();
-
for(int c = tabcount; c > 0; --c)
-
cout << " ";
-
cout << h.from() << endl;
-
-
MimeEntityList& parts = pMe->body().parts();
-
-
// cycle on sub entities list and print info of every item
-
MimeEntityList::iterator mbit = parts.begin(), meit = parts.end();
-
for(; mbit != meit; ++mbit)
-
printMimeStructure(*mbit, 1 + tabcount);
-
}
I think that it parses a mail file and print the FROM, am I right??
Cause I'm trying to pass to this function a file, that I open in main(), using this: - //my posted code
-
ifstream is;
-
is.open ("text.txt", ios::in );
-
-
is.seekg (0, ios::end);
-
len= is.tellg();
-
is.seekg (0, ios::beg);
-
-
buff= new char [len];
-
-
is.read (buff,len);
-
-
istreambuf_iterator<char> test1(is), test2;
-
int VarTest = imTestP | imTestE;
-
MimeEntity me(test1, test2, VarTest );
-
printMimeStructure(&me);
But it doesn't parse anything!
In fact instead of printing the From field it prints '/'.
Something wrong in my posted code??
I've done these passes, but the funny things is:
1) Start without Debugging;
2) VS2k5 opens the DOS window;
3) I can see only the flashing _ of DOS and nothing else;
4) after some seconds the system is slowing down and it freezes, have to restart!!
I think that the problem is here: - MimeEntity me(bit,eit); // parse and load message
-
printMimeStructure(&me); // print msg structure
In fact if I comment out these lines, I can see the:
"Press any key to continue . . ."
nothing else but the program exits instead of doing an infinite loop!
Is anyone able to tell me quite specifically what this code does??
Any help is appreciated!!
It is next to impossible to tell what an almost random piece of code is supposed
to do; especially if the presumed author of that code also doesn't know what it
does or is supposed to do. C++ doesn't help you one bit here because of all
that fancy operator overloading. Any guess is as good as another.
kind regards,
Jos
It is next to impossible to tell what an almost random piece of code is supposed
to do; especially if the presumed author of that code also doesn't know what it
does or is supposed to do. C++ doesn't help you one bit here because of all
that fancy operator overloading. Any guess is as good as another.
kind regards,
Jos
The funny thing is that the presumed author isn't me, but the author that releases the code that generates the library, which I'd like to use.
But I don't understand how this code doesn't work at all (the one that the author posted on his homepage).
Btw thank you for the answer! Bye
The funny thing is that the presumed author isn't me, but the author that releases the code that generates the library, which I'd like to use.
But I don't understand how this code doesn't work at all (the one that the author posted on his homepage).
Btw thank you for the answer! Bye
You do know that the majority published on home pages is just trash don't you?
I'd say: contact the author about this piece of code. All the best.
kind regards,
Jos
You do know that the majority published on home pages is just trash don't you?
I'd say: contact the author about this piece of code. All the best.
kind regards,
Jos
No, if I publish something on my blog (C++ ideas or code) I release working code! :D
Thank you again!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Oeln |
last post by:
If I want to check for input of an integer I've got the following (I
get the form input with $input = "$_POST"):
if(!ereg("^+$",$_POST)) {
echo "Input is incomplete or incorrect.";
}
If,...
|
by: Gregory Lielens |
last post by:
Hello all,
I am not sure this is the correct list to ask as my problem is really
related to python low level implementation, but as I do not have found a
python.dev list, here it is :-)
We...
|
by: Nick R |
last post by:
I need to know how to input bits from a *.wav file.
I have tried this:
#include <fstream>
....
ifstream fin;
fin.open("/root/foofile.wav", ios::in|ios::binary);
and then inputting...
|
by: sam |
last post by:
Hi, I've been buried in xsl and xslt articles for several days now, and am
still unsure as to what I need to do...
Basically, my vb.net app loads up an XML file from an external source...
|
by: google |
last post by:
first, a little background...
i have a C program which preprocesses some data, and then outputs the
results into a text file. that text file, in turn, is used as input
to a FORTRAN...
|
by: Michel Rouzic |
last post by:
I know it must sound like a newbie question, but I never really had to
bother with that before, and I didn't even find an answer in the c.l.c
FAQ
I'd like to know what's the really proper way...
|
by: dei3cmix |
last post by:
Hey, I am having a problem with a program I am working on. Basically,
the first part of the program gets input from a file using cin.getline.
Then the second part, (still in the same main as the...
|
by: Ed Jay |
last post by:
I'm dynamically creating several form input elements:
mValue = integer constant;
for(var j = 0; j < mValue; j++) {
target = "imgCn"+ j;
eName = "myFile"; eName = eName+jj;...
|
by: dmoran21 |
last post by:
Hi All, I am working on a program to take input from a txt file, do
some calculations, and then output the results to another txt file.
The program that I've written compiles fine for me, however,...
|
by: Bert |
last post by:
Hi, I'm unhappy: why doesn't this work?
char enc;
char temp;
for(int i=0;i<10000;i++){
fscanf(in,"%s",&temp);
if(temp=='#')break;
else
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |