help with strings

This is a discussion on help with strings within the C++ Programming forums, part of the General Programming Boards category; I'm writing a program...and I don't fully understand strings and pointers at the moment. I'm taking in a sentence from ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    8

    help with strings

    I'm writing a program...and I don't fully understand strings and pointers at the moment.

    I'm taking in a sentence from a user using the gets() function.
    How can I determine how long the string is? I declare the string as char string1[80]; But if the user's sentence isn't 80 characters long, is there a function I can use to determine the size? Also, what header file(s) do I need to include.

    Any help would be greatly appreciative.

    Dave (bgbfflochp@aol.com)

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    strlen - it's in string.h

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Use strlen() to determine a char string's length:

    strlen(string1)

    #include either <cstring> or <string.h>

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. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 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