Archives for the ‘C++’ Category

Indenting your code — convenient tab to space conversion

OK, so UltraEdit is not that expensive and I have yet to see an unfavorable opinion of it. But Notepad++ works fine for me, and as of today it works even better. Like most everybody, I indent my code. I use tabs for that. Tabs are convenient, but they are set to different widths for [...]

The class string vs. C-style strings

My previous C++ post illustrated how structs worked. The same example -- reading student names and grades from a .csv file into an array of Student structs -- can be used to illustrate the differences between C-style strings -- null-terminated arrays of characters -- and the class string. The advantage of using the class string, [...]

Structs

School's out, and structs were the last thing I learned about in this C++ class I took at NC State. This semester was really about the C in C++. The object-oriented part comes in the spring. But by the time you get around to structs, you will have learned about file streaming, arrays, global constants, [...]

Debugging C++ code (UNIX)

This assumes you're inside a UNIX terminal window (e.g., PuTTY session to remote UNIX box). Compile a .cpp source file in the GNU debugger: g++ -g -Wall -o mysourcefile.out mysourcefile.cpp Before starting gdb, make sure you're in the same directory as the executable just compiled above. Then call gdb: add GNU Then start the gdb [...]