Getting a string array size from a parsed string
Say u have a function like so..
void func()
{
char szString[64];
GetFileName(szString);
}
// How do I get the array size of the parsed string?
// The below code returns 4 (the size of the pointer or something)
void GetFileName(char *szString)
{
// Get the array size of the string
int len = sizeof(szString);
// Ive also tried..
lev = sizeof(*szString);
// And..
lev = sizeof(&szString);
// len returns ''4''
// Need len to be ''64''
....
....
}
Is there a way to do it properly?
Downloads: ZeroOne Realm
There's a builtin C function to do exactly this!
It's called "STRLEN".
usage:
strlen(s1) Returns the length of string s1
Ptim
There is no off position on
the genius switch
Edited by - ptim on February 26, 2001 8:08:43 PM
It's called "STRLEN".
usage:
strlen(s1) Returns the length of string s1
|
Ptim
There is no off position on
the genius switch
Edited by - ptim on February 26, 2001 8:08:43 PM
-=-=-=-A M I N O T M E R C I F U L ! ? ! ?
Worth noting is that the value returned doesn''t count the 0x00 at the end of the string. So if you are checking it for enough room to copy it or allocating space for it you have to add one to the length that strlen gives you.
Keys to success: Ability, ambition and opportunity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement