LJ Archive

Listing 1. Trivial C++ Program

(gdb) list 1,30
1        #include <fstream.h>
2        #include <strings.h>
3        #include <stdio.h>
4
5        const unsigned int REF_SIZE = 80;
6
7        class entry {
8             char *e_text;
9             char e_reference[REF_SIZE];
10       public:
11             entry(const char *text,
12                   const unsigned int length,
13                   const char *ref) {
14                  e_text = new char(length+1);
15                  strncpy(e_text, text, length+1);
16                  strncpy(e_reference, ref, REF_SIZE);
17              }
18       };
19
20       main(int argc, char *argv[])
21       {
22              char *text_1 = "Finding errors in C++ programs";
23              char *ref_1 = "errc++";
24              entry entry_1(text_1, strlen(text_1), ref_1);
25
LJ Archive