Program received signal SIGSEGV, Segmentation fault

If you are on Linux, try running valgrind. You just compile with -g (with gcc), and then run your program with valgrind in front: Unlike the GCC solutions, which tell you when the segfault occurs, valgrind usually tells you exactly when the first memory corruption occurs, so you can catch the problem much closer to its source. PS. It rhymes … Read more

Regex Explanation ^.*$ [duplicate]

^ matches position just before the first character of the string $ matches position just after the last character of the string . matches a single character. Does not matter what character it is, except newline * matches preceding match zero or more times So, ^.*$ means – match, from beginning to end, any character that appears zero or more times. … Read more

Does C have a “foreach” loop construct?

C doesn’t have a foreach, but macros are frequently used to emulate that: And can be used like Iteration over an array is also possible: And can be used like Edit: In case you are also interested in C++ solutions, C++ has a native for-each syntax called “range based for”

How do I add the MinGW bin directory to my system path?

To change the path on Windows XP, follow these instructions, and then add the directory where you install MinGW plus bin. Example: if you install MinGW in C:\ then you have to add C:\mingw\bin to your path Just for completeness here are the steps shown on the link: From the desktop, right-click My Computer and click Properties. In the System Properties window, click on the Advanced tab. … Read more

Parsing XML with Ruby

As @pguardiario mentioned, Nokogiri is the de facto XML and HTML parsing library. If you wanted to print out the Id and Name values in your example, here is how you would do it: A few notes: at_xpath is for matching one thing. If you know you have multiple items, you want to use xpath instead. Depending on your document, namespaces can be problematic, … Read more

Integer range when using 64bit jdk

The size of an int in Java is completely independent of the 32-bitness or 64-bitness of a JDK. It is always 4 bytes = 32 bits = −2,147,483,648 to 2,147,483,647. If you want a 64-bit integer, use a long, which is always 64 bits = 8 bytes.