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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum characters in string

Status
Not open for further replies.

daph

Programmer
Jun 9, 2000
65
0
0
CA
Hi,

Anyone here know the maximum number of charaters possible in a string?

Ex: char string[MAX];

Thanks,

Daph
 
C itself has no limit to the length of a string.

Your C compiler / OS may have other ideas though.

And it depends on whether such an array is global or local to a function.
 
i compiled it in Turbo C & C++ Compilers

global is Maximum of char string[65534]
local is Maximum of char string[65535]

i've no other compilers availble in this net center
 
DJ911, that's the 64K limit of 16-bit programming (I think). I suspect the difference of 1 is a mistake. In either case you can store 64K of characters MINUS ONE, because the string has to be terminated.
 
lionehill
please check it on older version of Turboc201
see the different of Globla & Local ur self
 
I'm not disputing you saw a real difference. I'm disputing that there should be a difference. Even compilers aren't right about everything! The only difference between global and local in a 16bit system is which segment is used (ds, ss), and that makes no difference to the available size of a segment.
Incidentally, have a go at making a local string 65535, or even 65534 bytes long and filling it with characters. See what happens. I'd almost be prepared to bet it fails. After all, the stack segment has to contain the odd function return address too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top