MonthFebruary 2010

C++ Trimming Leading or Trailing Spaces

One can use one of the string methods find_last_not_of and find_first_not_of. What these methods do is that they return the index of the string where the character in that index does NOT match what you are looking for.

For example:

[code]string str = " TEST STRING "; //there is a space in the beginning and end

cout << str.find_first_not_of(" ") << endl; //this line will return a 1, because thats the first thats not of a " "[/code]

To get rid of the leading and trailing spaces in that string, we can do this:

[code]str = str.substr(str.find_first_not_of(" "));  //str will now be assigned "TEST STRING ", note that there is still a space at the end

str = str.substr(0, str.find_last_not_of(" ") + 1) //now the trailing space is removed.  a 1 is added because without it, we would get "TEST STRIN" instead.  the 1 ensures that only the space is removed[/code]

Free Texting/SMS (Online Services and E-mail)

Personal note:  I did notice that if I tried e-mailing a Fido or Rogers number, the recipient will not receive the message you sent, and instead they will get a message telling them how to retrieve the message.  It seems like a convoluted way of doing things.  It works perfectly with Bell Mobility.  Replies get sent to your inbox too.
  • Rogers Wireless: [10-digit phone number]
  • Fido: [10-digit phone number]
  • Telus: [10-digit phone number]
  • Bell Mobility: [10-digit phone number]
  • Kudo Mobile: [10-digit phone number]
  • MTS: [10-digit phone number]
  • President’s Choice: [10-digit phone number]
  • Sasktel: [10-digit phone number]
  • Solo: [10-digit phone number]
  • Virgin: [10-digit phone number]

Windows Live Messenger/MSN (Or Any Program) Refuses to Open

Usually this happens because there is already a msnmsgr.exe process open in the task manager.  To remedy this, open up the task manager by pressing Ctrl-Alt-Del and clicking Task Manager, or Start > Run > taskmgr.

Find all instances of msnmsgr.exe and end those processes, and then reopen the program

This fix is usually applicable to programs other than MSN.  In a way it is also a general solution for programs refusing to open.

Creating Symbol Files from Block Diagrams in Quartus II

Open the file you want to make a symbol for

Click File > Create/Update

Select “Create Symbols Files for Current File”

Quartus II Block Diagram and Simulation Tutorial

Describes how to create new projects, block diagrams, and simulation of block diagrams.

Does not discuss how to use the USB Blaster

WordPress Proofreading Settings

That WordPress proofreader has become very annoying.

You can configure the proofreading feature by going to My Account -> Edit Profile from the Dashboard.

My Thoughts on Polyphasing

Even though I only tried it for that one night, I felt that I got a lot of work done during the night.  I’d like to try it out more some time.  However, getting used to it is going to be pretty tough.  Since I only did it for a night, there isn’t really much to say about it.

Startup Folder

Anything put in this folder will automatically be executed when the computer starts up.

Hidden Folder

C:Users(User-Name)AppDataRoamingMicrosoftWindowsStart MenuProgramsStartup

C++ String to Double or Integer Conversion

[code]string str = "some number in the form of a string";

double a;

int b;

a = atof( str.c_str()); //conversion to double

b = atoi( str.c_str()); //conversion to int[/code]

If the string that is being converted is actually not a number, then it will return a zero.

Running XP-Mode on Windows 7 Machines without Hardware Virtualization


Any edition of Windows 7 other than Home
VMWare Player (free)

© 2017 Henry Poon's Blog

Theme by Anders NorénUp ↑