The TMediaPlayer component should be able to play with any codec installed on your computer.

Can you play the file normally using Windows Media Player from Explorer?

His question is why the rewritten stuff on Windows 7 works so much faster than what he had been using.

@OP:
You state that you are using CopyFileEx() (a Win API function) on Unix systems and it is going slow. Assuming your original code does not have any hooks on the call, it is at least going through an emulator (Wine, presumably), not to mention the overhead of going over network protocols.

You then state that you are using SHFileOperation() to have the Windows Shell perform the same function call and it is running faster, but on a native Windows 7 machine.

Without seeing your code for both the original and the rewritten stuff, I can only assume that playing with the OS emulator is costing you.

I notice you are spamming the forum with a lot of questions that you could easily get the answer to by simply reading the documentation or simple searches on Google.

What about my answer to this same question needs you to start another thread to ask it again?

commented: thats not spamming thats testing bro +0

There is no exhaustive list, because each compiler system + OS has their own.
There are common, standard ones, though.
Here's the GNU CPP's documentation.

Hope this helps.

Why are you subtracting 1 on line 11?

Plenty of people still program with ancient, pre-standard compilers, particularly in places like India.

Also, there does exist the WinBGIm port for MinGW, so old BGI code certainly can and does compile with modern GCC.

Alas, I am currently reinstalling my compiler (I managed to hose it with an 'automatic update' process -- never trust those), so I cannot compile and test your code right now. That said, I don't see anything obviously wrong with it.

What exactly is the error you are getting when you run it?

No. All (normal) messages go to a window event handler.

The functions you write to handle events can, of course, be as window agnostic as you like.

commented: thanks +3

Quicksort over a non-random access sequence is, I admit, tricky.

Why is everyone trying to quicksort a linked list?

I hesitate to link to another site for your answer, but your question about how to use qsort() is entirely answered in the FAQ here. It explains how qsort() works and gives an example of randomizing data with it. That comparison function is the key to making it work.

Hope this helps.

You are not being specific -- your question is very vague.

So far as I can tell, you want to display 1000 things in 20 slots, but without any way of recycling the 20 slots.

I wish I could say. Richedit does have some random issues.

1) Make sure you are linking to the most current RichEdit DLL (4.1).
2) Make sure your window with the RichEdit control is not doublebuffered.
3) Make sure your manifest is correct.

I assume you are using the RichEdit's scrollbar and not linking to one of your own?

Is there something left out about the format of the data you are searching?

There is no way to search random data faster than O(n).
However, if your data were sorted then you could search it in O(log n).

Also, every time you add extra code to do something the loop already does, you increase the amount of time it takes to work.

What is this for? An algorithms class? Or basic CS?

I'm confused. Are you talking about a circular buffer?

stty is not the best option for this.

You should first look to see if the environment variable $COLUMNS exists. It is most likely to be correct.

Failing that, use the command tput cols to query the terminal size.

If you really want to do it properly though you'll have to use ioctl() with TIOCGWINSZ.

Hope this helps.

You go try to use std::sort with std::list first.

And this is a very obvious homework problem, either from an actual school or from a book.

Neither std::sort() nor quicksort are appropriate for sorting a linked list.

Further, homeworks typically expect you to do the sorting yourself.

To be clear, no, you cannot override static methods. (You can overload them, though.)

The reason is simple: a static method cannot appear in a class's virtual function table, so it is not inherited. In order to call a static method you must know exactly what type of object you are calling it from.

A quick example:

#include <iostream>

struct Foo
{
  static void speak()
  {
    std::cout << "Hello\n";
  }
};

struct Bar: public Foo
{
  static void speak()
  {
    std::cout << "No.\n";
  }
};

int main()
{
  Foo* baz = new Bar;
  baz->speak();
}

Give it a run.

Even though it is actually a Bar you've got, the compiler sees that you've got a pointer to a Foo and calls Foo::speak().

What would you have to do to make it say "No"?

That's right. Cast.

static_cast <Bar*> (baz)->speak();

By now, you may wonder if using the pointer stuff isn't overkill.

Well, actually, it is. You might as well just call the static methods directly.

Foo::speak();
Bar::speak();

Hope this helps.

That code is wrong in a number of subtle and dangerous ways. But what it is trying to do is write the binary value of a 'PasswordGenerator' object to file.

Any object you wish to write should have a function to explicitly convert it to either text or binary. If you google around "serialization" you'll find all kinds of stuff, but it might be overload.

Here's a simple example to get you going:

// Here's our fictional object type.
// It contains an integer (very easy to write to file)
// and a string (not so easy).
class Quux
{
  private:
    int         x;
    std::string s;

  public:
    Quux( int x, const std::string& s ): x(x), s(s) { }

  // The stream insertion operator must be a friend
  friend std::ostream& operator << ( std::ostream&, const Quux& );

  // As must be the stream extraction if you intend to read a Quux from stream
  friend std::istream& operator >> ( std::istream&, Quux& );
};

// Here's a function to turn a string like [Hello "Bill"] into [Hello \"Bill\"]
std::string quote( const std::string& s )
{
  std::string result;
  for (char c: s)
    switch (c)
    {
      case '\\': s += "\\\\";
      case '\"': s += "\\"";
      // You can add any other transformation you like here. For example, 
      // you can turn newlines into [\n] with  case '\n': s += "\\n";
      default:   s += c;
    }
  return result;
}

// Here's the stream insertion operator function, which writes a string that looks like
//
//   quux ...

Using a library and decoding an image yourself are two totally different things.

The OP cannot change his compiler's environment, but there is never any restriction on the files you can create for a single-user directory (outside of diskspace, of course).

Using CImg would work fine.

(I know this is old. Has OP solved his problem?)

What you've got seems to introduce but not use 't', and has a bug on line 16 (when temp->next is NULL).

Also, you are endeavoring to do two things at once: sort and display. Don't do that. Put the sort stuff in its own function.

Sorting is not particularly easy, but the simplest sort you might employ over a singly-linked list is called insertion sort.

You'll need two lists -- an empty one (new_head) and the one you wish to sort (head).

While there are elements in head pop off the first one.

Find where it belongs in new_head and insert it there. (You should have a function to insert a node in your list, right?)

When you are done, just return the new_head list from the function.

(And yes, this is an N-squared algorithm, but for your homework lists you shouldn't notice.)

Hope this helps.

Hey all.

I'm always frustrated that I cannot seem to find a reference that shows when a feature was introduced in Delphi.

For example, to use ErrOutput, I have to manually create that value in D5. But what about D6? or D7?

Does such a reference exist?

Apple is putting a lot of effort into LLVM. Unfortunately, the LLVM debugger doesn't work with FPC (yet, AFAIK).

You'll either have to get an old copy of the GDB or install an older version of X-Code (you can do this side-by-side with your current version).

Alas, I don't have access to a Mac and I don't know any better than this. I just noticed that no one has answered your question...

Hope this helps.

It is not egotistic to simply respond to having one's [i]very simple[/i] code roundly abused. The function has the performance and memory characteristics desired when I wrote it. It has no leaks. It does what it is supposed to do. And it isn't filled with convoluted, non-standard stuff.

I've responded to the syntax error you have actually shown me by correcting it, but you have yet to respond by showing exactly how my function has a "logic error" or what all these unnamed "bug"s are. Instead you have resorted to [i]ad homenim[/i] by personally belittling my understanding, experience, imagination, and behavior.

Bye.

[quote=Narue]Looks like a bug to me. Addition of pointers is both nonsensical and illegal in C. I see what the author was going for, but it seems especially awkward. I'd rather just keep a running count of the string length and set [inlinecode]block[/inlinecode] to the current null character on each iteration. It's much simpler that way:[/quote]
[quote=Narue]You're correct. While addition of pointers is illegal, even if you fixed it, there's still a logic error in that line.[/quote]
Pointer arithmetic is [i]not[/i] illegal. What is illegal is to perform arithmetic on [i]unrelated[/i] pieces of memory. The pointer arithmetic was not a mistake; however I could have been more careful to code it as:
[code] block = ok + (size_t)(block - result) - 1;[/code]
Since you are in to giving a code review, I'd sure like to know exactly what the logic error is in that line. It seemed me some pretty simple addition for me that kind of error.

Also, I don't think that there is any point in keeping an extra variable around to track information that is already available in [inlinecode](block - result)[/inlinecode]. If I were developing under some specific company guidelines that addressed stuff like that I could easily adjust to do just as you would. Otherwise it comes down to nothing more than simple, personal preference.

[quote=vedro-compota]as i see - this original auther code won't work at all (even without bug about which line we spoke earlier ...[/quote]
Those are pretty careless statements to make, considering you ...

commented: + +3

Your program needs to take the file name as argument. Example program:

[code=C++]

include <fstream>

include <iostream>

include <limits>

using namespace std;

int main( int argc, char** argv )
{
// Make sure the program has at least two arguments:
// 1: the program's executable path
// 2: the file name passed to your program
if (argc != 2)
return 1;

// Open the argument file
ifstream f( argv[ 1 ] );

// If the file could not be opened, we're done.
if (!f)
return 1;

// This example program just counts the number of lines in the file...
size_t num_lines = 1;
while (f.ignore( numeric_limits <streamsize> ::max(), '\n' ))
++num_lines;

f.close();

// ...and displays the count to the user
cout << "The file \"" << argv[ 1 ] << "\" contains " << num_lines << " lines.\n";

// Keep the console open long enough for the user to see the result.
cout << "Press ENTER to quit.";
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );

return 0;
}
[/code]
Hope this helps.

It should also be noted, in addition to [b]StuXYZ[/b]'s excellent comments, that you should get an entire [b]Student[/b] before adding a copy of it to the vector.

Your choice of variable names is pretty good, actually, but I will nit-pick about the vector name: "sNames" -- first, it isn't a vector of student [i]names[/i], it is a vector of student [i]data[/i], which includes the name. A good name for a collection of [b]Student[/b] is "students".

So, remember, the order to do things is:
[LIST=1]
[]Get all the information about a student into a single [b]Student[/b] object.
[
]Use [b]push_back[/b]() to append a [i]copy[/i] of that [b]Student[/b] object to the vector of [b]Student[/b]s.
[*]Repeat.
[/LIST]

Also, I notice you have variables starting with the prefix "temp". You never use them, so get rid of them. (Delete lines 21 and 22.)

Remember, a [b]Student[/b] is not just a [i]name[/i]. It is a collection of information about one particular student: his first name, last name, and all his grades.

[code=C++]
// Here is the list of students we wish to populate.
vector<Student> students;

...

// This loop gets 'numStudents' students from the user.
for (int i = 0; i < numStudents; i++) {

// This is the temporary variable we'll use to hold information
// about a single student as we get it from the user.
Student student;

// Now, gather the individual pieces until we have them all.

cout << "Enter the first name for student #" << (i + 1) << ": ...

That's because the answer given you is not correct -- the [i]very first[/i] form auto-created in your DPR is the application's [i]main[/i] form -- which is not what you want.

You still need to edit the DPR, but in a different way. If you google around "delphi spash screen" you'll get some good hits, like this one:

[url]http://www.delphi-central.com/splash.aspx[/url]

Good luck!

I'm actually surprised you posted something like this, as it is a dangerous function -- especially for newbies who don't really know what the consequences of using it are.

Typically, a GUI should not be Sleeping/Delaying at all. If you [i]must[/i] pause for some reason, use one of the [URL="

Require your users to use specific input formats. Something like "M 36 John Doe Mary F 45" is nonsense at best and malformed otherwise. If you have [i]two[/i] people then that should assume [i]two[/i] inputs. If your user puts nonsense into the program, tell him!

So, You can assume one of the following by specifically [i]restricting[/i] your user to:
Given Name, Surname, Age, and Sex, where the name is in one of the standard forms: "First Last" or "Last, First".
[code]
M 36 John Doe M 36 Doe, John
36 M John Doe 36 M Doe, John
M John Doe 36 M Doe, John 36
36 John Doe M 36 Doe, John M
John Doe 36 M Doe, John 36 M
John Doe M 36 Doe, John M 36
[/code]
You can easily determine which is which by examining the type of the string.
If you have "M" or "F" or "Male" or "Female" or "m" or "f" or "male" or "female" or "MALE" or some other variation, then you know it represents the sex. If you have a number than it should represent the age. Otherwise it must be a name: If it ends with a comma (,) then it represents the last name -- otherwise it is given name. The next name item is either the surname or the given name, depending on what the first encountered name is.

There is a potential issue, mind you. Not all people have such simple names. Something like "Juaquin Antonio Carrera ...