by Forrest Sheng Bao http://fsbao.net
I just made a video tonight on how to debug a C++ program in anjuta, the open-source C/C++ IDE for Linux. anjuta is one component of GNOME development suite and thus part of GNOME project. I think it is very good, just a bit worse than Apple Xcode. But it is definitely way better than Microsoft Visual Studio. Microsoft should do some study on user interface design. Proper menu design, window layout and usability is more user-friendly than eye candies. Sadly, Microsoft focuses too much on eye candies, and makes using their software like dating a girl - every step is very complex.
by Forrest Sheng Bao http://fsbao.net
I want to talk about two common errors people encounter when they compile old programs, especially when they are using recent version of g++. They may wonder why this code can be compiled in g++3.4 but not g++4.3.
A lot people get shock when they see this:
error: fstream.h: No such file or directory
The answer to solve this problem is that "Header files in the C++ Standard Library do not use the .h extension; have have no extension," -Kyle Loudon, C++ Pocket Reference, p.5, O'Reilly, 2003. So instead of saying
#include <fstream.h>
, you should say
#include <fstream>
by Forrest Sheng Bao http://fsbao.net
Well, the trick is very easy, call system.
#include "stdio.h"
#include "assert.h"
int main ()
{
char buffer [50];
sprintf (buffer, "ls");
printf (buffer);
assert(system(buffer) >= 0);
return 0;
}