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

© 2018 Henry Poon's Blog

Theme by Anders NorénUp ↑