strings

This is a discussion on strings within the C++ Programming forums, part of the General Programming Boards category; I didnt include my code for my Stack on here. I want to say if string is not empty, then ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Location
    Indiana
    Posts
    99

    strings

    I didnt include my code for my Stack on here. I want to say if string is not empty, then push each character onto stack. This isnt my whole code but just the part where Im stuck at. Do I have create a bool empty maybe?
    Code:
    int main(){
    
         Astack S;
         string s;
    
         cout <<"Enter data:";
         getline(cin, s);
    
         if(!s.empty){
             S.push(s);
           }

  2. #2
    Registered User
    Join Date
    Dec 2010
    Posts
    1
    hello,
    i have some problem about my project..
    can u help me to solve lcd.h function
    the problem is unable to locate the lcd.h...

  3. #3
    Registered User
    Join Date
    Feb 2009
    Location
    Indiana
    Posts
    99

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    2,692
    Since "s" is a std::string then "empty" should be a function.

    Code:
    if(!s.empty()){

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 02:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 07:07 PM
  3. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:34 AM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM

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