William Hemsworth 1,339 Posting Virtuoso

im really lazy, and this seems like alot of effort.

Well that's too bad, because here you have to make an effort in order for us to make an effort to help you.

Your idea is good, just don't let the idea overwhelm you, do it in parts. Does this function have to work with different data types too?

William Hemsworth 1,339 Posting Virtuoso

Yeh, it wont work. For example in the very first part, you want to change this:
314.41778E-2 to 31 and 4.41778E-2
However it could also be:
3 and 14.41778E-2 or just 314.41778E-2

So AFAIK, it's impossible unless you have have some way of knowing where the number starts or ends.

William Hemsworth 1,339 Posting Virtuoso

I actually only started using the computer when I was about 8/9 years old, the earliest game I cam remember playing is Age of Empires :P

On my old Sega Master System (which I still have), the first I can remember playing in Portugal when I must have been about 4 years old, was Sonic the Hedgehog. Good times.

edit: found it with an emulator attached :)

Grn Xtrm commented: The old Sonic games rule! +0
William Hemsworth 1,339 Posting Virtuoso

Seriously though - do you trust Microsoft? Do you trust Apple? You shouldn't. They are working towards their own best interests, which quite probably are not your best interests.

Their best interests also has to satisfy our best interests, or they will quickly lose users, so no I don't agree. A good OS will attract more users, and it's not like Microsoft hasn't got enough money to provide us with a good one.

William Hemsworth 1,339 Posting Virtuoso

And your nickname doesn't seem to fit with your attitude. Curious.

If you don't have anything decent to add, then shut up with these pointless remarks.
Just accept that you're not going to convert anybody who reads this away from Windows, it's a waste of time.

William Hemsworth 1,339 Posting Virtuoso

Hello William,

Yes you are correct your code does change only the first one. My mistake.

The code was compiled on a different computer, in order to recompile it I need to setup all the proper libraries with the proper versions (the code was compiled quite a few years ago). I am getting the libraries, but I thought it might be quicker just to modify the binary file. After looking into the code I see that there are some other places where value of 60.0f is used (there are also 9 places where I see 60.0f in the binary file). I would be disappointed if the code optimization process resulted in 9 constants with the same type and value, hence I am afraid that changing the binary would not do. Though through the investigation I have found that constants are stored towards the end of the executable.

Thanks a lot.

Copy and paste the unmodified project somewhere, and play around with the binary a bit.

William Hemsworth 1,339 Posting Virtuoso

Nice :D serves them right.

William Hemsworth 1,339 Posting Virtuoso

May I ask why you don't want to compile the sources? And as for the program I made, it only changes the first 60.0f found, it would have to be modified to do any more. How many variables do you have assigned with the value 60.0f in your application?

William Hemsworth 1,339 Posting Virtuoso

I took this as a challenge, and managed it. I'm sure there's better ways, but.. it work perfectly for me. Compile this code, put your program in the same directory with the correct name, then run it.

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

int main() {
  ifstream in( "infile.exe", ios::in | ios::binary );
  float toFind = 60.0f;
  float toReplace = 50.0f;

  if ( !in ) {
    return 1;
  }

  union {
    float f;
    struct {
      char bytes[ sizeof(float) ];
    };
  };

  int counter = 0;
  while ( in.read(bytes, sizeof(float)) ) {
    if ( toFind == f ) {
      in.seekg( ios_base::beg );
      break;
    }
    counter += sizeof(float);
  }

  ofstream out( "fixed.exe", ios::out | ios::binary );

  while ( counter-- ) {
    out.put( in.get() );
  }

  out.write( (char*) &toReplace, sizeof(float) );

  in.ignore( 4 );
  char ch;
  while ( in.get(ch) ) {
    out.put( ch );
  }

  cout << "Done.\n";
  cin.ignore();
}

Hope this helps.

sinnerFA commented: Nice job, works! +0
William Hemsworth 1,339 Posting Virtuoso

Windows has advantages?

Yup, you implied so yourself.

Oh, they may repair it for other people, but they won't use it for themselves, except possibly for gaming.

But that's obviously the comeback most Windows users would make, but besides that, there's plenty. One major advantage is that it's currently the most widely used OS, and has the most software available.

Now, I would like to hear some real reasons as to why recent versions of Windows are so bad that you felt the need to create this rant, not your current response of "It's garbage".

lllllIllIlllI commented: zing +0
William Hemsworth 1,339 Posting Virtuoso

the MacBook Pro is virus and spyware proof, networks like a dream (I don't have an IT department - don't need one), and just works.

One thing PC users can do that Mac users can't.

Your whole post was just plain annoying, if people are comfortable with Windows, why do you care? Just give it a rest, you will always get people with different opinions, and as Tom Gunn said, rants like these are a waste of time.

My opinion is that all three operating systems are fine, each with their own advantages which appeal to different people.

majestic0110 commented: Nice link :) +0
jasimp commented: Yes!! LOL I was hoping someone would link that. +0
William Hemsworth 1,339 Posting Virtuoso

Each page is taking me 20-30 seconds to load, it's pretty frustrating :icon_neutral:
Is there a reason for this?

nav33n commented: Its frustrating indeed.. +0
William Hemsworth 1,339 Posting Virtuoso

Show me your code so far, on Window Forms it's easy.

William Hemsworth 1,339 Posting Virtuoso

What about nuclear bombs

What about them? I thought the question was if it affects your health and how old you look, a bomb would just kill you. Besides, it's the people who fire them.

Technology, like a lot of things has it's advantages and disadvantages, but in this case it's simply outweighed. It also allows us to maintain our health too, imagine how many people would die if hospitals were inexistent.

You can give up all non-essential technology and become Amish if you like.

William Hemsworth 1,339 Posting Virtuoso

Does your cousin ever go to the gym, do any sports, or keep himself active at all? That's the main problem, people submerge themself in technology so much that they do start to damage their own health. There's nothing wrong with technology, the problem is human fitness, everybody has time to stay healthy.

Nick Evan commented: corrrrect! +0
William Hemsworth 1,339 Posting Virtuoso

Search the web, we're not here for these sort of one-answered homework questions.

William Hemsworth 1,339 Posting Virtuoso

Not sure if I like it. I got 3 negative votes for posts where I posted help

Don't take them seriously, it was most probably just one guy being an idiot :P

William Hemsworth 1,339 Posting Virtuoso

My guess would be because of this problem. [link]

William Hemsworth 1,339 Posting Virtuoso

I've wasted many hours of my life on that site :icon_eek:

William Hemsworth 1,339 Posting Virtuoso

Heap Memory: [link]
Stack Memory: [link]

William Hemsworth 1,339 Posting Virtuoso

Normally I think unions are place inside structures

They can also be very helpful outside structures, for example in this snippet I made some time ago. [link]
I used it in the main scope as a structure inside of a union instead of the other way round. It helps when you want to assign values quickly. In fact, in the Pixel struct, i use a struct inside a union inside a struct :)

dkalita commented: good one +1
William Hemsworth 1,339 Posting Virtuoso

Check the code snippets here, there's loads on this topic.

William Hemsworth 1,339 Posting Virtuoso

im glad to join this forum!!

Glad to have you too :P but code tags here is a must. All you have to do when writing your post is:

blah blah blah, and the code i'm currently struggling with is:

[code] CODE HERE [/code]

I'm sure you can manage that.

William Hemsworth 1,339 Posting Virtuoso

Does it mean that fstream does not include iostream, or is it specific to g++ compiler.

One windows header file usually includes 10/15 others, you can never be sure if it's included until you check. Besides, there's no harm in putting #include<iostream> again, that's what header guards are for.

g++ did not compile this and says that there is no matching call for the last statement. Isn't there a constructor in the class ofstream which accepts a string object as argument?

ofstream doesn't take an std::string as an argument, it has to be a const char*. Here's your fixed code:

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

void do_something()
{
  string fname;
  cin >> fname;

  ofstream fout(fname.c_str());
  // Do stuff with fout
}

int main()
{
  do_something();
}
William Hemsworth 1,339 Posting Virtuoso

oH! thanks maN! that really helpS!!! :D!!

Capital letters go at the start of a sentence, not the end. :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

Great, after three threads of being told to post the code, you don't use code-tags :icon_confused:
Please, read the rules too.

William Hemsworth 1,339 Posting Virtuoso

First, does the book come with a CD that includes a program in which to create flash projects.

You will have to get that yourself, as far as I know there's a few different programs you can use such as Adobe Flash CS2/CS3 or Adobe Flex 2/3. I've seen the difference between AS2 and AS3, I still use AS2 and it's very easy to use, AS3 in comparison looks very excessive and hard but it's supposed to be much more powerful, so the choice is yours. I was given Macromedia Flash 8 free in highschool, and i'm still most comfortable with it :)

I'm not sure how easy it is to get it for free, you can probably still find Macromedia Flash 8 somewhere on the internet, but it uses AS2.

I've never done anything graphical before. Will I still be able to learn effectively from your recommended book?

Maybe do a few tutorials on the net first, and you will be ready for the book, it should be a nice change if you've never done anything graphical before.

I actually think having a Flash forum on Daniweb would be a great idea, it's a very popular language and I would for sure post there alot :P

do you happen to know roughly how much that book costs in American currency?

Simply change the .co.uk to .com, and you're done. [link]

Grn Xtrm commented: Thanks for the info. +0
William Hemsworth 1,339 Posting Virtuoso

If you do want to start flash, I can recommend some excellent books for you. Forgot the name of the first one I started with, but if you're into the advanced maths and game designing, this is by far the best i've tried. [link] (I actually used the AS2 version, but I'm guessing you would rather use the most up-to-date version)

It's very fun, flexible, and easy to learn.

William Hemsworth 1,339 Posting Virtuoso

Well, I was lucky enough to have a taiwanese friend introduce me to Flash around the age of 11. Then I figured out a bit of AS2 and bought myself a few books, I actually still use it alot, here's a few examples of stuff I made: Spirograph maker, Spiral maker, Command Drawer (actually quite similar to MSLogo) and Organised Chaos. Then I decided I wanted to try something a bit more powerful, that's when I started using C++ and got interested in the Windows API mainly.

I guess I was quite fortunate to have started young, even made myself quite a bit of money from it here and there :icon_cool:

Don't think that you need a teacher to learn programming, I'm totally self taught, meaning I can go at my own pace. If you do the same, you'll probably find yourself going at a faster pace than in school.

William Hemsworth 1,339 Posting Virtuoso

I wish I had a programming class in high school.

I wish I didn't, it's frustrating when you know you should be teaching the teacher how to program.

William Hemsworth 1,339 Posting Virtuoso

Sorry, I think I found another one :icon_rolleyes: On one thread, a post had 2 up-votes, I down-voted it and it fell to 0 votes. I tested it again on this post when it had 3 up-votes (one of them may have already been mine), and it went down to 1, and when I up-voted it again, it jumped to 3. Is it supposed to do that? and what about if I want to put it on 2?

William Hemsworth 1,339 Posting Virtuoso

AD even wrote a snippet to do something similar. [link]

William Hemsworth 1,339 Posting Virtuoso

Good point :) Youtube comments have to be the worst of all.
http://xkcd.com/202/

William Hemsworth 1,339 Posting Virtuoso

If it's just a number and that we shouldn't get worked up about it (i.e. it's not sufficiently important), is there any real need for it?

There's no need to get worked up about it if you get down-voted once or twice, that doesn't mean the system's useless. You're not supposed to take the rep system seriously either, doesn't mean we should get rid of it.

This system (or pretty similar) was implemented on a couple of other forums I used to use and was taken down sharpish.

It's also been implemented on many other sites successfully, such as Youtube, StackOverflow, Digg, and many more.

William Hemsworth 1,339 Posting Virtuoso

Seems to be a bug, did the same on this post.

William Hemsworth 1,339 Posting Virtuoso

As I mentioned, if you give reputation you automatically vote.
Or you can vote without giving reputation.

It was my understanding that if somebody gives you reputation, it automatically gives a vote. On this post, I got given rep while (I think) my current rating was still 0. If that's the case, shouldn't it be 1? or have I just misunderstood this?

Dani commented: Maybe a bug. Testing testing 123. +0
William Hemsworth 1,339 Posting Virtuoso

I've to admit that the union approach was just a bad and clunky advice.
But I just can't get this:
Why would someone use an unportable function to do the job when there's a portable function which will also help you to achieve the same job?
It's of course his choice, but I'd know which one to choose.

Because, I like it, it's a simple function which has one purpose, to convert an integer to string (with a radix). If anybody complained that they couldn't compile my code on a crap compiler, I wouldn't care. Also, if portability was a big issue for me, I could just add this to the start of my code.

#define itoa my_itoa
char *my_itoa(int _Val, char *_DstBuf, int radix) {
  static const char vals[] = "0123456789abcdef";
  int c = _Val, d = 1, dif, i;
  int _signed = _Val < 0;

  while (c /= radix) ++d;

  i = d + _signed;
  if ( _signed ) _DstBuf[0] = '-';

  for (; i - _signed; --i) {
    dif = (_Val % radix);
    _DstBuf[i - 1] = (_Val /= radix, vals[(dif < 0 ? -dif : dif)]);
  }

  _DstBuf[d + _signed] = 0;
  return _DstBuf;
}

Which - I would never have to :P It's just a matter of personal preference in the end, I've never liked the format of sprintf and functions like that so much, which cause me more trouble altogether than itoa does.

tux4life commented: Heh, nice code :) +6
William Hemsworth 1,339 Posting Virtuoso

Do your own homework.

William Hemsworth 1,339 Posting Virtuoso

That -2 was probably because people didn't like your opinion, and you came along as being slightly agressive and unwilling to give things a chance. The numbers say what people think of your post, that's it, it doesn't take into account whether the person who voted was an idiot or not. I think you're taking it a bit too seriously.

Change is never easy to get used too, I still prefer the old daniweb style, some people prefer the new style more though, and I'm not willing to argue over it.

William Hemsworth 1,339 Posting Virtuoso

How does one gain a trusted certificate?

Hell do I know? :D
All I did was 30 seconds of googling to come to that conclusion,
I'm sure you can figure it out if you put your mind to it.

William Hemsworth 1,339 Posting Virtuoso

If you want to 'copy' the string into a character buffer, you have to do something along the lines of:

char *newStr = new char[str.length()+1];
strcpy( newStr, str.c_str() );

// Deal with newStr

delete[] newStr;
William Hemsworth 1,339 Posting Virtuoso

You clearly didn't search hard.

str.c_str() // returns a constant pointer to its characters
William Hemsworth 1,339 Posting Virtuoso
if else(keyStroke) = 65 || 97 || 69 || 101 || 73 || 105 || 79 || 111 || 85 || 117

You can't do that, you would have to do:

else if ( keyStroke == 65 || keyStroke == 97 /* ect */ ) {
   <code>
}

In fact, just start over and read this. [link]

William Hemsworth 1,339 Posting Virtuoso

Every one of your if-statements is wrong. The syntax is supposed to be:

if ( <condition> ) {
   <code>
}

Yours is:

if ( <condition> ); { // Get rid of that semi-colon
   <code>
}

Also, lines 39, 42, 55, and 58 need some serious rewriting, and please, indent your code correctly.

William Hemsworth 1,339 Posting Virtuoso

I really like that when a thread has had no replies, the 0 is bolded and in red.

Heh... yeh :cool: Saving those precious seconds.

William Hemsworth 1,339 Posting Virtuoso

As Dani said, it's another way to indicate if there has been some interest in the thread. I found myself using it, so it can't be that useless.

William Hemsworth 1,339 Posting Virtuoso

Plus the bold numbers next to the threads, get rid of those and I would be happy.

I agree with that, it looks slightly untidy there at the left, this was briefly mentioned in Area 51 too. I think that part just needs a bit of redesigning, but I don't want to get rid of it altogether.

William Hemsworth 1,339 Posting Virtuoso

Another person against it :)

http://www.daniweb.com/forums/post1004252.html#post1004252

Boo Hoo. People need to give things a chance, they're just not used to the small differences.

Please Dani, take them away, my eyes hurt.

I don't get it, it's hardly changed. There's two small buttons and a number by each post, what's with all this overreacting? :icon_wink:

Dani commented: Hehe +0
William Hemsworth 1,339 Posting Virtuoso

What's your problem? and use code tags the next time you post code, or I promise wont reply.

William Hemsworth 1,339 Posting Virtuoso

It's not so bad, the most damage one person can do is -1. Every time I see a post I think shouldn't be voted down, I vote it up. Or, if you can't be bothered with that, ignore the voting system altogether, I'm sure other people will take care of it.

I find voting the voting system quite addictive somehow.