Thread: How do I find the length of this string

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    3

    How do I find the length of this string

    Hi all,

    Please review the code below. I need to find the length of the string to which, character pointer stringvar is pointing to:

    const char *stringvar = getenv("QUERY_STRING"); /* CGI input */

    if i write,

    int length = strlen(stringvar);

    will it give me the length of complete string?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yes, strlen gives the length of strings. When in doubt, read the fine man page.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Well, you should also read the man page for getenv() and make sure you don't do anything stupid if it can't find the "QUERY_STRING" variable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to find out the length of a printf before it's printed
    By Richardcavell in forum C Programming
    Replies: 13
    Last Post: 04-08-2011, 03:26 PM
  2. find the maximum width & length of a box using for loops?
    By bac3bac0mm in forum C Programming
    Replies: 1
    Last Post: 03-17-2011, 10:23 PM
  3. Find String length and Arraysearch
    By s.rajaram in forum C Programming
    Replies: 5
    Last Post: 10-03-2007, 02:28 AM
  4. how to find string length without using counter
    By nitinmhetre in forum C Programming
    Replies: 4
    Last Post: 09-03-2007, 06:42 AM
  5. how do I find the length of and array using sizeof()
    By raymond1234 in forum C Programming
    Replies: 9
    Last Post: 04-27-2007, 02:38 AM

Tags for this Thread