445,804 Members | 1,631 Online
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

# finding the length of a char*

 P: n/a How can I find the length of a character pointer in 'C'? TIA Dec 11 '05 #1
9 Replies

 P: n/a Al-Burak wrote: How can I find the length of a character pointer in 'C'? By posting to comp.lang.c Dec 11 '05 #2

 P: n/a Al-Burak wrote: How can I find the length of a character pointer in 'C'? If you mean the number of chars in the array the pointer points to, then the general answer is: you can't. If this pointer points to an array, where the end of the array is signalled by a 0-char, then you can use strlen. hth -- jb (reply address in rot13, unscramble first) Dec 11 '05 #3

 P: n/a Al-Burak wrote: How can I find the length of a character pointer in 'C'? With sizeof(char*). Dec 11 '05 #4

 P: n/a Thanks folks! The function I was looking for is strlen(). TIA Dec 12 '05 #5

 P: n/a Neelesh Bodas wrote: Al-Burak wrote: How can I find the length of a character pointer in 'C'? By posting to comp.lang.c To the OP: You could have avoided such replies by leaving out the word 'C' in your question or by replacing it with 'C++'. Since you specified a language that this group is not about you get smart-ass answers like the above. However, without having specified the language as something other than C++ your question would have been totally on-topic. Dec 12 '05 #6

 P: n/a Use strlen() Dec 12 '05 #7

 P: n/a Al-Burak wrote: Thanks folks! The function I was looking for is strlen(). be careful with strlen, because it counts until a '\0'... the array could be more longer ;-) Dec 12 '05 #8

 P: n/a Neelesh Bodas wrote: Al-Burak wrote: How can I find the length of a character pointer in 'C'? By posting to comp.lang.c sizeof(char*); length returned is in bytes. Ben Pope -- I'm not just a number. To many, I'm known as a string... Dec 12 '05 #9

 P: n/a Al-Burak wrote: How can I find the length of a character pointer in 'C'? TIA If you mean the length (size would be a more appropriate term) of a character pointer then just use 'sizeof(char*)'. For the length of a string pointed to by the character pointer use 'strlen'. Jan 24 '06 #10

### This discussion thread is closed

Replies have been disabled for this discussion.