Thread: help with strings

  1. #1
    Registered User
    Join Date
    Mar 2002

    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 (

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    strlen - it's in string.h

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


    #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, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08: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