c++ StreamReader Substring visual studio.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • collinse@gmail.com

    c++ StreamReader Substring visual studio.net

    **** PLEASE HELP ME *************** *************** ******
    ***** SEE BELOW********** *************** *************** *
    StreamReader* sr = File::OpenText( path);
    try {
    String *s = "";

    int place = 0; // looks for the ID FIELD
    String *ID_val = "IAO_"; // ID is the leader if the id
    String *ID;
    String *temp;
    while (s = sr->ReadLine()){
    place = s->IndexOf(ID_val );
    if ( place == 1)
    {
    Console::WriteL ine(s->Substring(1,8) ); //this works
    temp = s->Substring(1,8) ; // this is my problem
    }}
    // i just want to save the substring as a string.

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: c++ StreamReader Substring visual studio.net

    So what is the problem?

    Also, you realize that IndexOf returns the zero based index, so unless
    you expect the place to be at the second character, you might want to
    compare it against zero.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <collinse@gmail .com> wrote in message
    news:1111433224 .412007.242590@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > **** PLEASE HELP ME *************** *************** ******
    > ***** SEE BELOW********** *************** *************** *
    > StreamReader* sr = File::OpenText( path);
    > try {
    > String *s = "";
    >
    > int place = 0; // looks for the ID FIELD
    > String *ID_val = "IAO_"; // ID is the leader if the id
    > String *ID;
    > String *temp;
    > while (s = sr->ReadLine()){
    > place = s->IndexOf(ID_val );
    > if ( place == 1)
    > {
    > Console::WriteL ine(s->Substring(1,8) ); //this works
    > temp = s->Substring(1,8) ; // this is my problem
    > }}
    > // i just want to save the substring as a string.
    >[/color]


    Comment

    • collinse@gmail.com

      #3
      Re: c++ StreamReader Substring visual studio.net

      temp = s->Substring(1,8) ; // this is my problem
      this line will not work however the line before this one works fine.
      why will substring not work with stringreader? please help me..........

      Comment

      Working...