Solved

Efficient way to get a string contains at most 3000 chars

Posted on 2004-04-10
33
635 Views
Last Modified: 2008-03-04
I am trying to read a file into a string and crypt it, I don't want to use getline (since some of file does not have any specific character such as '\n'), read by char and crypt it is too slow, so I would like read amount of characters into a string, and then just crypt it.
I select 3000 character each time I read from file, my code like below...
CAN SOMEONE TEACH ME MORE EFFICIENT WAY TO DO THIS JOB???

THANK YOU SO MUCH....

//======================================================
// The code is work, but I would like to know if any efficient way to do this job... Thanks
//======================================================
const int AMOUNT = 3000;
......
ifstream ifile;
string filename = "c:\\test.txt";
ifile.open(filename.c_str());
if(!ifile.is_open())
    return;

string str = "";
char c;
while(!ifile.eof())
{
   str = "";
   for(int i = 0; i < AMOUNT && !ifile.eof(); i++)
   {
       ifile >> c;
       str += c;
   }
   doCrypt(str);
}
0
Comment
Question by:billcch
  • 13
  • 10
  • 3
  • +3
33 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 10796952
Why don't you just use fgets(char*, size, FILE*) ?
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 10796959
hmm; ignore that comment; I forgot that fgets() terminates upon finding a '\n'....
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10796969
Use ifstream::read(char *buffer, int size), so in your case this would be

char buffer[AMOUNT];
ifile.read(buffer, AMOUNT);
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10796982
Do you have to use STL? If not, you can use standart FILE structure and fopen, fread, fclose functions..
Your should code something like this:

FILE *fp;
char buffer[3000];
size_t bytesRead;

fp = fopen( "C:\\test.txt", "rb" );
if( fp == NULL )
     return;

while( !feof( fp ) )
{
     bytesRead = fread( buffer, 3000, 1, fp );
     doCrypt( buffer, bytesRead );    
     // I just thought you should pass the length of the buffer instead of using a string terminator
}

fclose( fp );
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10797354
caner_elci, I understand where you are coming from, but this is the C++ TA :-)
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10797410
Sure it is :)
Anyway, I'm not that much into STL, so my answer was easy and quick one "for me"..

Cheers,

Caner ELCI
0
 
LVL 30

Expert Comment

by:Axter
ID: 10797507
If you want something that is more efficient then ifstream or fread, then you'll need to use OS specific map file methods.

What is your OS?
0
 
LVL 30

Accepted Solution

by:
Axter earned 300 total points
ID: 10797558
Here's an example read member function as khkremer suggested, but with std::vector as the string buffer.
You can still easily use a std::vector object with a function that takes a std::string object.

Example:

void doCrypt(const std::string& str)
{
      cout << str << endl;
}


int main(int argc, char* argv[])
{
      const int AMOUNT = 3000;

      ifstream ifile;
      string filename = "c:\\test.txt";
      ifile.open(filename.c_str());
      if(!ifile.is_open())
         return 0;

      std::vector<char> str(AMOUNT, 0);
      while(!ifile.eof())
      {
            ifile.read(&str[0], AMOUNT);
            doCrypt(std::string(str.begin(), str.end()));
      }
      
      system("pause");
      return 0;
}

0
 
LVL 30

Expert Comment

by:Axter
ID: 10797578
FYI:
You could use a std::string object directly with the read member function.
However, this method is not safe, and certainly not portable.
If you're familiar with your std::string implementation, and portability is not an issue, this an alternative method, but ill adviced method.

std::string str(AMOUNT, 0);
while(!ifile.eof())
{
      ifile.read(&str[0], AMOUNT);
      doCrypt(str);
}
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10804040
The fastest way is to use the system calls - availlable in   C++   as well :)  open, read.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#define MAXLEN 3000

// . . .


char buf[MAXLEN];
int h,len;

h = open ( "C:\\test.txt", O_RDONLY | O_BINARY );    // remove "| O_BINARY" if you are not on windows or if error

if ( h < 0) { printf ("Error cannot open file\n") ; return; }

// 'len' is the number of bytes read

while ((len = read (h, buf, MAXLEN)) > 0)  doCrypt (buf, len);    

close( h );
0
 
LVL 30

Expert Comment

by:Axter
ID: 10804140
>>The fastest way is to use the system calls - availlable in   C++   as well :)  open, read.
That's not correct.

The {open, read} function sets do not have buffering.  Where as the {fopen, fread} sets do have buffer, which makes them faster when making multiple read or write.
ifstream/ofstream also has buffering.

The {open, read} function set are part of the original C file functions which had limited functionality and no buffering.
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10804174
There is a buffering at low level.

And we don't need a high level buffering as
1. data is read only (no write)
2. data is read once only

It is why the system calls are the fastest.
0
 
LVL 30

Expert Comment

by:Axter
ID: 10804261
>>There is a buffering at low level.
Modern OS have the low level buffering, but this is outside the scope of the C++ language.
Since you're comment reffered to "availlable in   C++", the OS would not be considered.
In any case, the user hasn't stated what OS is being used, so we're not even sure if there is an OS low level buffering.

>>And we don't need a high level buffering as
>>1. data is read only (no write)
>>2. data is read once only

High level buffering is for read and write.
In the example code you posted, there's a read inside a loop, which means you're making multple reads.
The high level buffering optimizes the read by buffering so that the number of hits on the physical drive is reduced.

Even if this buffering did not occur, the {open, read} function sets would not be faster, and more then likely would be less efficient.
More over, you're buffering would be OS dependant, and therefore your code performance would be OS dependant.
0
 
LVL 10

Assisted Solution

by:Mercantilum
Mercantilum earned 200 total points
ID: 10805055
Well... since I didn't agree [I think most of the buffering optimisation is done at system level], I made a simple program [see below]
- sys_doit () function doing my way  (open ,read)
- cpp_doit () function doing your way  (istream.open/read)

Compiled with g++ 3.3.3 under Linux SuSE 8.2

    g++ -O2 test.cpp -o test

The test file (test.dat) is 190MB large. Results :

  sys-1 took 396ms
  cpp-1 took 474ms
  sys-2 took 394ms
  cpp-2 took 469ms

The system calls are  faster  than c++ ifstream stuff. I'm not surprised as ifstream is based on system calls at low level, and the file being read only once, c++ cannot rely on more than system. You will notice that the 2nd time is a bit better, as some tables are already in memory. [if you try at home, run the program twice]

---------- Program -----------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#include <sys/time.h>

struct timeval tt;

void start()
{
  gettimeofday(&tt, NULL);
}

unsigned long end()
{
struct timeval t;

  gettimeofday (&t, NULL);
  return (t.tv_sec*1000 + t.tv_usec/1000) - (tt.tv_sec*1000 + tt.tv_usec/1000);
}


#define MAXLEN  3000

void sys_doit (char *fn)
{
  char buf[MAXLEN];
  int h,l;

  h = open(fn, O_RDONLY);

  if (h<0) return;

  while ((l=read(h, buf, MAXLEN)) > 0)
  {
  }
  close(h);
}

#include <iostream>
#include <fstream>
using namespace std;

void cpp_doit (const char *fn)
{
  char str[MAXLEN];
     ifstream ifile;
     ifile.open(fn);

     if(!ifile.is_open()) return;

     while(!ifile.eof())
     {
          ifile.read(str, MAXLEN);
     }
     ifile.close();
}

int main (void)
{
  start () ; sys_doit ("test.dat");
  printf ("sys-1 took %ldms\n", end());
  start () ; cpp_doit ("test.dat");
  printf ("cpp-1 took %ldms\n", end());
  start () ; sys_doit ("test.dat");
  printf ("sys-2 took %ldms\n", end());
  start () ; cpp_doit ("test.dat");
  printf ("cpp-2 took %ldms\n", end());
}
---------------------------------------------------------------
0
 

Author Comment

by:billcch
ID: 10805119
Thanks everyone!
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10805194
Before someone comes back to say "Yeah but it's Linux!", I just tried on a (poor) pc windows XP (cygwin) :

  sys-1 took 422ms
  cpp-1 took 941ms
  sys-2 took 391ms
  cpp-2 took 933ms

Ouch!
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10805237
So what was wrong with my suggestion to use ifstream::read()?
0
 

Author Comment

by:billcch
ID: 10805483
khkremer:
Sorry...
you are right, you are the first one suggest me ifstream::read()....
I should give you the point too.........
Thanks and Sorry again...
0
 
LVL 30

Expert Comment

by:Axter
ID: 10805509
>>Mercantilum
That's not a good test.
Your mixing types.

For it to be an accurate test you should have used {open,read} set with {fopen,fread} set.
Or compared fstream with iostream.

Since you're mixing object with c-Style functions, you can not accurately determine if it's the class implementation causing the difference or if it's the buffering.

You need to compare apples with apples, and not apples and oranges.

Furthermore, you would have to do a lot more work to remove optimization that would also hinder your test.
It's very easy to get mis-leading results if you're not experience in properly setting environment for a proper performance test.  And I don't even consider myself to be experience enough to do a good performance test without having a peer review.
0
 
LVL 30

Expert Comment

by:Axter
ID: 10805531
billcch,
If you're a paying member, you have unlimited points, and you can easily post a second question for khkremer, and award him points.

If not let me know, and I'll post points for him/her myself.
0
 

Author Comment

by:billcch
ID: 10806320
khkremer, caner_elci and mrwad99
Please copy one of your answer here
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20951149.html
so I can give the point to you!

THANKS EVERYONE....
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10807018
@Axter:  Including fread, results:

*** Linux
Using system calls, open and read : time 398 ms
Using higher calls, fopen,  fread    : time 479 ms
Using C++ calls, ifstream class      : time 464 ms
Second call:
Using system calls, open and read : time 396 ms
Using higher calls, fopen,  fread    : time 474 ms
Using C++ calls, ifstream class      : time 466 ms

*** Windows
First call:
Using system calls, open and read : time 393 ms
Using higher calls, fopen,  fread    : time 762 ms
Using C++ calls, ifstream class      : time 926 ms
Second call:
Using system calls, open and read : time 389 ms
Using higher calls, fopen,  fread    : time 761 ms
Using C++ calls, ifstream class      : time 925 ms

Are we mixing apples and oranges ? in order to prove that on linux and win XP the simple system calls open and read are faster than both fopen/fread and ifstream class (for read) the program had to incorporate C and C++ code... so am I mixing c-style objects and a class ? Ok, just provide the small part of code of the cpp_doit function with no cstyle object (well, if the trick is to use a vector for str, it won't be faster :) ...

Come on, the 3 functions have a 1-2 lines loop, and are very simple, calling one API ... it shows clearly that on linux and xp, the code proposed above using fread/ifstream is slower than the one using the system calls. What kind of buffering do you expect, while the file is read only once ?! And the file would be read n times, the OS takes care of maintaining the pages in memory if the file is not modified, ifstream or fread won't be better.
Why are they slower ? Simply because open read process the request with no more checking.

For system basic things, use system api... if you need speed.

--------program incl fread-----------------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#include <sys/time.h>




struct timeval tt;

void start()
{
  gettimeofday(&tt, NULL);
}

unsigned long end()
{
struct timeval t;

  gettimeofday (&t, NULL);
  return (t.tv_sec*1000 + t.tv_usec/1000) - (tt.tv_sec*1000 + tt.tv_usec/1000);
}


#define MAXLEN  3000

void sys_doit (char *fn)
{
  char buf[MAXLEN];
  int h,l;

  h = open(fn, O_RDONLY);

  if (h<0) return;

  while ((l=read(h, buf, MAXLEN)) > 0)
  {
  }
  close(h);
}

void f_doit (char *fn)
{
  FILE *fp;
  char buffer[3000];
  size_t bytesRead;

  fp = fopen( fn, "rb" );

  if( fp == NULL ) return;

  while( !feof( fp ) )
  {
     bytesRead = fread( buffer, 3000, 1, fp );
  }

  fclose( fp );
}

#include <iostream>
#include <fstream>
using namespace std;

void cpp_doit (const char *fn)
{
  char str[MAXLEN];
     ifstream ifile;
     ifile.open(fn);

     if(!ifile.is_open()) return;

     while(!ifile.eof())
     {
          ifile.read(str, MAXLEN);
     }
     ifile.close();
}

int main (void)
{
  printf ("First call:\n");
  start () ; sys_doit ("test.dat");
  printf ("Using system calls, open and read : time %ld ms\n", end());
  start () ; f_doit   ("test.dat");
  printf ("Using higher calls, fopen,  fread : time %ld ms\n", end());
  start () ; cpp_doit ("test.dat");
  printf ("Using C++ calls, ifstream class   : time %ld ms\n", end());
  printf ("Second call:\n");
  start () ; sys_doit ("test.dat");
  printf ("Using system calls, open and read : time %ld ms\n", end());
  start () ; f_doit   ("test.dat");
  printf ("Using higher calls, fopen,  fread : time %ld ms\n", end());
  start () ; cpp_doit ("test.dat");
  printf ("Using C++ calls, ifstream class   : time %ld ms\n", end());
}
---------------------------------------------------------------------------------
0
 
LVL 30

Expert Comment

by:Axter
ID: 10808677
>>@Axter:  Including fread, results:

Still not a good test.
I commend you for your effort, but like I stated before, it’s takes some experience to conduct a good valid performance test.

First of all, you’re still testing ifstream, which is not relevant in the manner you’re testing it.  So I’ll ignore that all together. (apples and oranges).

The fopen test is not using the same code logic as the open logic.  So that also makes your test invalid.
In the following lines, you have an extra function call for fopen test, which of course will make it less efficient then the open function.
while( !feof( fp ) )
  {
     bytesRead = fread( buffer, 3000, 1, fp );
  }

It should look more like the following:
  while((l = fread( buf, 1, MAXLEN-1, fp )) > 0)
  {
  }
So as to match it’s counter part.

You also do nothing with the variable that you’re reading into.  That means your compiler can optimize away the function all together.
Here’s a more valid test:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#define MAXLEN  3000

char dummyvar[MAXLEN];

void sys_doit (char *fn)
{
  char buf[MAXLEN];
  int l;
  int h = open(fn, _O_RDONLY);

  if (h<0) return;

  while ((l=read(h, buf, MAXLEN-1)) > 0)
  {
        buf[l] = 0;
        strcpy(dummyvar, buf);
  }
//  printf("%s\n", dummyvar);
  close(h);
}

void f_doit (char *fn)
{
  char buf[MAXLEN];
  size_t l;
  FILE *fp = fopen( fn, "rb" );

  if( fp == NULL ) return;

  while((l = fread( buf, 1, MAXLEN-1, fp )) > 0)
  {
        buf[l] = 0;
        strcpy(dummyvar, buf);
  }

//  printf("%s\n", dummyvar);
  fclose( fp );
}

#define QtyTest 11111

int main (void)
{
      int i;
      DWORD StartTime, LenTime1, LenTime2, LenTime3, LenTime4;
      StartTime = GetTickCount();
      for(i = 0;i<QtyTest;++i) sys_doit ("c:\\test.dat");
      LenTime1 = GetTickCount() - StartTime;


      StartTime = GetTickCount();
      for(i = 0;i<QtyTest;++i) f_doit ("c:\\test.dat");
      LenTime2 = GetTickCount() - StartTime;

      StartTime = GetTickCount();
      for(i = 0;i<QtyTest;++i) f_doit ("c:\\test.dat");
      LenTime4 = GetTickCount() - StartTime;

      StartTime = GetTickCount();
      for(i = 0;i<QtyTest;++i) sys_doit ("c:\\test.dat");
      LenTime3 = GetTickCount() - StartTime;



      printf("Time duration is as follow:\
                  \nsys1 = %li\nf1 = %li\nsys2 = %li\nf2 = %li\n",
         LenTime1, LenTime2, LenTime3, LenTime4);

      if (!dummyvar[0]) printf("\n");
      system("pause");
    return 0;
}
0
 
LVL 30

Expert Comment

by:Axter
ID: 10808768
You'll notice that in my previous comment I stated that the above code is a MORE valid test.

This code however, would still not pass a 100% valid testing code, because it doesn't have enough code logic to remove all possible compiler optimization which could spoil the test.

The above code runs on Windows, but could be easily modified for UNIX/Linux.

When I ran it, the difference in speed fluctuated 2% up and down.

Meaning, sometimes sys_doit was faster by up to 2%, and sometimes f_doit was faster by up to 2%.
In other words, there was no practical measurable difference.
I ran my test on Windows 2000 machine.

Running a performance test is not a laymen’s game.
As if you’re doing a scientific experiment, you want to make everything the same as much as possible, and the only variable should be what you want to measure.

Any thing else that is different in the test, can be a factor in throwing the test off, and therefore making the test invalid.
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10810333
1. Of course the functions read  *only*  the file, and did not copy the data (for instance) as what we want to test is the speed of read, not the one of strcpy! If the compiler would have optimized the code, it would have simply missed the API calls, which it didn't obviously (otherwise time would be almost zero). The test is "read the data" not "read the data and do lengthy operations after", since, of course, all times would tend to be the same...
(btw, as stated first, lines may not end with '\n', so it's likely they're not always text ... by using x[len]=0, strcpy you will miss some data :)

2. Ok, fread does not need the eof(). result after optimization: still 16% difference!
            Using system calls, open and read : time 397 ms
            Using higher calls, fopen,  fread    : time 472 ms
   [ new line: while ((bytesRead = fread( buffer, MAXLEN, 1, fp )) > 0) /*nothing*/;  ]

4. ifstream: this is the code you gave to the author! do you mean your code was not the faster?
  I said "open/read" will be faster, you said "No it won't. " - tests show that for pure reading of the file, open/read is faster.
  "yeah but you use ifstream", yes I use the one you gave in your solution!
  Give me another cpp_doit() function, more efficient, and we'll see if it is faster than open/read!
  Are we mixing oranges and apples? simply doing the same operation! ifstream is more powerful? maybe, but - again - for simple operations like reading a file, the system open and read will be faster.
0
 
LVL 30

Expert Comment

by:Axter
ID: 10810557
>> ifstream: this is the code you gave to the author! do you mean your code was not the faster?

I never said ifstream would be faster, nor did I claim anything I posted to be the fastest.

I'm only referring to your claim that open/read is faster then fopen/fread function sets.

>>Are we mixing oranges and apples?
Yes, you are.  As I've stated, I've never claimed ifstream to be faster then using a C-Function open/read.
What I did say is that fopen/fread would be faster the open/read.  I then went on to say that ifstream has buffering, but I left it at that.
The speed of ifstream really depends on the implementation, so it would be difficult to make a claim on its efficientcy.

This is the last I have to say about ifstream, since I don't know any other way to make it clear, that it's not part of the debate.

As far as your last results, I'm not sure how you could have gotten that.  But since you haven't posted the modified code, you could still have things in your code that is throughing things off.
On my test, there's not difference between the two.  However, if the OS did not have cache, fopen/fread would be faster.
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10810678
>> ifstream depens on the implementation
ok, so can you provide another implementation, faster?? what does ifstream at low level ? It calls the open/read system functions.
It depends on the implementation, and on both linux and windows it's slower :)

Remember, you said initially fread/fopen ifstream/ofstream do buffering, not open/read.
Well, as we saw before, open and read do buffering, through the OS.
Since MS-DOS do you an OS being used which does not buffering ??
Even MS-DOS got a driver to do buffering later on.
What kind of buffering would be done for fread not done for read?? Why the compiler would take care of buffering while it is typically an OS job!?

You said, "I tested and 'read' is only 2% faster" - well, at least it's faster :) but let see the algo:

mine 16% diff:
  while (read (data)) { }
yours 2% diff:
  while (read (data)) { copy data }
I suggest you try:
  while (read (data)) { do 10 times { copy data  } }

you'll see the difference between fread and read to be < 1% :)

>> speed is OS dependant for OS buffering
sure, and APIs are compiler dependant... well, open/read is faster on linux and xp ...
what do you think fread does at low level ? It calls 'read' ... it's why on unix, for instance, open and read are in the 2-System calls family, while fopen fread are in 3-C library functions family. The "3" family calls the "2" family. Sure "3" is more sophisticated in terms of programmer convenience, and it could implement special buffering etc... but in our case, again, mulitple sequential reads of a file once, the system calls are faster.


The modified code ? This is the same, besides the fact that fread does not use eof() anymore, just the f_doit() changed:

---
void f_doit (char *fn)
{
  FILE *fp;
  char buffer[MAXLEN];
  size_t bytesRead;

  fp = fopen( fn, "rb" );
  if( fp == NULL ) return;
  while((bytesRead = fread( buffer, MAXLEN, 1, fp )) > 0);
  fclose( fp );
}
0
 
LVL 30

Expert Comment

by:Axter
ID: 10816016
>>You said, "I tested and 'read' is only 2% faster" - well, at least it's faster :) but let see the algo:
No.  That's not what I said.  You seem to be reading what you want to read.
I said there was a 2% difference up and down.  That means sometimes fread was faster then read, and sometimes read was faster then fread.

>>This is the same, besides the fact that fread does not use eof() anymore, just the f_doit() changed:
So you're saying with the above code changes, you're still getting 16% difference?
If so, the fopen/fread function set must have a very poor optimization for your library.

Of course, if you run this in DOS only mode, you'll notice that fread is much faster then read.
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10820574
Yes, it has still 16% difference  *without*  doing the lengthy copy operation of course :)
Anybody can try the code I provided using a good compiler...
...talking to that, I used  g++ 3.3.3  one of the best library around.
0
 
LVL 30

Expert Comment

by:Axter
ID: 10821038
>> g++ 3.3.3  one of the best library around.

It's one of the best library for portability, but it's NOT a good library for optimization, and it's a poor choice for performance test.

That's why you're getting such bad results.
If you used a compiler that is built for optimization, you wouldn't be getting those results.

>>Anybody can try the code I provided using a good compiler...

A good *OPTIMIZE* compiler, will give you results closer to what I posted, and will certainly not give you a 16% difference.

The GNU compiler is a really good compiler for portability.  In fact, it's the best portable compiler available.
However, the portability comes at a price.  And that price is poor optimization and performance.

Therefore, this certainly would not be the compiler of choice for making a case on any C/C++ performance issues.
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10821057
Ok ok :)
Will you tell me that MS VC++ is better than g++?
0
 
LVL 30

Expert Comment

by:Axter
ID: 10821107
>>Will you tell me that MS VC++ is better than g++?

ONLY in optimization (and of course IDE).

The GNU compiler is better at portability.

The GNU compiler is more compliant to the standard then VC++ 6.0
However, VC++ 7.1 is more compliant to the C++ standard then the GNU 3.x version.

The GNU compiler is still more compliant to the C-Standard then is 7.1, which I consider a real let down.

However VC++ 6.0, 7.0, and 7.1 have all higher optimization then the GNU 3.x compiler.

Which one is better, depends on what is more important to the paticular developer. (performance, portability, compliance, Good-IDE).

My personal favorite is VC++ 6.0, mainly because of it's great IDE, which (IMHO) makes up for it's poor C++ compliance.

0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10821122
Well ... I thought that the power of thousands people working on open-source would provide better soft, especially for theorical matters, like compilers...
We have to keep in mind something though, it's not because a compiler gives the same timing for read and fread that it is better, it could that it simply bad for 'read' :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now