473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

finding the length of a char*

How can I find the length of a character pointer in 'C'?

TIA

Dec 11 '05 #1
9 85547

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
Al-Burak <ja******@netscape.net> 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
Al-Burak wrote:
How can I find the length of a character pointer in 'C'?


With sizeof(char*).

Dec 11 '05 #4
Thanks folks!
The function I was looking for is strlen().

TIA

Dec 12 '05 #5

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
Use strlen()

Dec 12 '05 #7
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Cengiz Ulku | last post by:
Hi, I've already posted a question similar but will need some precisions and help. I have a rtf file displayed within a RTB control. Above it, I have a text box control with a scroller which...
8
by: Ekim | last post by:
my question is as follows: I've got a DLL in which I have a method GetBuffer (this one is extern, exported, is called from outside this program) which shall pass a char-buffer to the...
20
by: ishmael4 | last post by:
hello everyone! i have a problem with reading from binary file. i was googling and searching, but i just cant understand, why isnt this code working. i could use any help. here's the source code:...
11
by: MackS | last post by:
I've come across the following difficulty, related to questions 6.12, 6.13 and 6.18 in the FAQ, which I am unable to overcome: void fun(char **array_of_strings, int num_elements); int...
0
by: fripper | last post by:
I have a VB .Net 2003 program that I am upgrading to VB 2005. It includes a data structure that defines an object containing a number of fixed length (stirng) fields. Somehting like the...
10
by: Dancefire | last post by:
Hi, everyone, I'm writing a program using wstring(wchar_t) as internal string. The problem is raised when I convert the multibyte char set string with different encoding to wstring(which is...
1
by: pedalpete | last post by:
I have a bunch of events which I extract from my database, some of these events extend over a night, some take place during a single day. In the database I have the start/end times of the event,...
2
vdraceil
by: vdraceil | last post by:
Hi,i'm using vb6.I have a command button which when clicked opens VLC Media Player and plays a specific file in it in full screen mode. Now i want the player to close itself after playing the file....
3
by: Maxood | last post by:
I have the following code: int* y = new int; where n's value will be provided by the user at runtime. I need to know the total memory size that i have allocated to y. What function i will...
6
by: TTheot | last post by:
Hallo everyone. I am trying to call an unmanaged C++ function, that has a structure as an input parameter. The structure is defined in the header file like this: struct MyStruct { int ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.