Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Array Passing Problems

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a character array of length 280 and when I pass it into a function in any way ( reference, value, etc.) it always says the size of the character array is now 4. Then on the next line of code, I have it print out the array and it is all still there but it lists the size as 4. Any ideas why this may be happening? Thanks
 
This, as weird as it seems, is correct. You sizeof operation is happening on a pointer and not the actual string. To determin the lenght of the string, use strlen. if it is not a string and just a buffer, pass the length into the function. Short of that, there is no way to determine the actual size.

matt
 
Thanks. Seems strange but i guess I can understand it. It worked so that's all that matters then. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top