pointer . substr

This is a discussion on pointer . substr within the C++ Programming forums, part of the General Programming Boards category; error is "left of ".substr" must have class/struct/union type. Shortened version of my code Code: std::string newtext; std::string * p; ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    128

    pointer . substr

    error is "left of ".substr" must have class/struct/union type.

    Shortened version of my code
    Code:
    std::string newtext;
    std::string * p;
    
    //newtext derived from function
    
    p= &newtext;
    
    while (!isalpha(*p.substr(counter, 1)) & (counter <=maxlen))
    {
    }
    error is on the while line. What is wrong?

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    try

    (*p).substr(counter, 1)

    or

    p->substr(counter, 1)

    and if it works, then look up the topic of operator precedence.
    You're only born perfect.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    128
    thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-24-2008, 10:16 AM
  2. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. How did you master pointers?
    By Afrinux in forum C Programming
    Replies: 15
    Last Post: 01-17-2006, 07:23 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21