Need Answer Quick

This is a discussion on Need Answer Quick within the C++ Programming forums, part of the General Programming Boards category; I passed in a char* into a function and I need to find out how many characters long it is..... ...

  1. #1
    Unregistered
    Guest

    Need Answer Quick

    I passed in a char* into a function and I need to find out how many characters long it is..... how do i do this?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Code:
    int length=lstrlen(char *);

  3. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    As long as you're 100% sure that there is memory allocated for the char* and it contains a '\0', then it should work.
    Code:
    int function(char *x)
    {
         int length = strlen(x);
         return length;
    }

  4. #4
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Otherwise pass the size along with the char*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. quick question
    By SenorJesucristo in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2006, 09:06 PM
  3. Quick question, should be simple to answer.
    By kabuatama in forum C Programming
    Replies: 4
    Last Post: 01-21-2006, 02:42 PM
  4. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  5. Quick Answer...
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 07-27-2002, 11:22 AM

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