English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Why is the size of most input buffers 256 bytes only? Is this dependent on processor or OS? The same program to read string of length more than 256 characters, gives erroneous result on unix and solaris systems. But the same program in VC++ gives correct string length. If the buffer size depends on OS, I cant get the correct result using Turbo C++ on the same Windows platform, where VC++ yielded correct result. Can anyone address this issue and suggest a method to get a string of greater than 256 bytes in one go? (however command line argument in C program can accept more than 256 characters and yield correct result)..

2006-11-22 17:10:23 · 2 answers · asked by Srini 1 in Computers & Internet Programming & Design

Why is the size of most input buffers 256 bytes only? Is this dependent on processor or OS? The same program to read string of length more than 256 characters, gives erroneous result on unix and solaris systems. But the same program in VC++ gives correct string length. If the buffer size depends on OS, I cant get the correct result using Turbo C++ on the same Windows platform, where VC++ yielded correct result. Can anyone address this issue and suggest a method to get a string of greater than 256 bytes in one go? (however command line argument in C program can accept more than 256 characters and yield correct result)..

FYI, I used both CC and g++ compilers in unix environment (32-bit), but still didnt get the correct length of string..

2006-11-22 17:27:48 · update #1

2 answers

Do not confuse the length of a buffer, which is determined by the author of the program, and the datatype / representation of the variable assigned to the input. The representation of many strings consists of a single byte containing the string length, plus the bytes of the string. It the string length representation that limits the length of the string variable.

2006-11-22 17:53:31 · answer #1 · answered by Computer Guy 7 · 0 0

Don't know which compiler you are using under UNIX env.... you can change that... also there is a method to increase this buffer size.

2006-11-22 17:20:56 · answer #2 · answered by Ronney 5 · 0 0

fedest.com, questions and answers