Monthly Archives: April 2012
read(), readline(), readlines() & xreadlines() func in Python
While doing a regression analysis, I had to read & parse through a large .dat file. I called readline() func but was surprised to see that I was actually iterating through every single character in the first line! with open(filePath, ‘r’) as f: for line in f.readline(): print line Then realization dawned upon me! * […]
Convert vowels to uppercase in a string
Given a string – say “hello world”, I was interested in capitalizing the vowels in it – IN A CLEAN & EFFICIENT WAY! In the first approach, I use a StringBuilder object to hold the intermediate String while in the second approach, I’m using a C# feature – Linq. In the second approach, there is […]
Error 1 error LNK1104: cannot open file
I had a similar issue few years back The same solution helped me in this case as well. You simply have to turn on ‘Application Experience’ feature under services.msc to get rid of the error!
Printing hex values using cout()
I wanted to display hex numbers and came across setf() & unsetf() functions which are quite useful to know of! There are different kinds of flags & masks you can use as well. Please refer http://www.cplusplus.com/reference/iostream/ios_base/setf/ for more information. #include <iostream> using namespace std; int main() { int num = 255; cout.setf(ios::hex, ios::basefield); cout << […]
How does a compiler tie an error message back to the source code?
Usually we see (C++/.NET) programs throwing exception messages which are not very informative. But at-least they direct me to the line from where the problem originated. How does the compiler do that? Compilers have two modes when building a program – DEBUG & RELEASE. By default, compiler builds the program in the debug mode & […]
Login