bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

c++ strings with gdb??


From: Dave
Subject: c++ strings with gdb??
Date: 15 May 2002 08:21:10 -0700

HI,

All right, I hope I find the right home for my question this time
after I was redirected from one group to another.

I tried my following code :
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main( int argc, char *argv[] ) {

  string linebuffer;
  string substring;
  ifstream inputfile;
  
  inputfile.open(argv[1]);//process them one by one
    
  getline(inputfile,linebuffer);//read in lines  

  substring=linebuffer.substr(0,1);
  
  inputfile.close(); 
  
  return 0;
} // main
after using the -g flag to complie the program with g++, I used gdb to
debug the program. Under gdb, I used "r in", where in the name of the
input file. It contains:
<A HREF="http://www.acm.org/technews/articles/2000-2/0112w.html#item15";>The
rush to XML</A>

When I used "p substring" to show the content of "substring", I got :
$10 = {static npos = 4294967295, static nilRep = {len = 0, res = 0,
ref = 1,
    selfish = false}, dat = 0x24340 "<A HREF=\"http:/"}
where the "dat" field is not the expected "<". And also, when I used
"p substring.substr(0,1)" to show the substring of "substring", I got
:
$11 = {static npos = 4294967295, static nilRep = {len = 0, res = 0,
ref = 1,
    selfish = false}, dat = 0x24340 "<A HREF=\"http:/"}
instead of "<" in the dat field. 

Could someone explain what is going on here?

Thanks for clarification.

BTW, why are there so many spam messages in this group, such as
"making money from home" or something like this? And there are also
many un-displayable characters on my screen for many messages. It is
just weird for me. ... Did I find the right group for dicussing gnu
gdb?...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]