m.kelas-karyawan-ftumj.prestasi.web.id Layanan Informasi 17 Jam
Telp/Fax : 021-8762002, 8762003, 8762004, 87912360
HP/SMS : 081 1110 4824 27, 0812 9526 2009, 08523 1234 000
WhatsApp : 0817 0816 486, 0812 9526 2009
email : _Hubungi Kami__ silahkan klik
Chatting dengan Staf :
ggkarir.com
ggiklan.com
Pilih Bahasa :   ID   EN   Permintaan Katalog / Brosur (GRATIS via POS)   Kelas Karyawan   Reguler
D3 Komputer AkuntansiD3 Analis Farmasi dan Makanan (Anafarma)S1 Teknik Komputer / Sistem KomputerS1 PsikologiS1 Kesehatan MasyarakatS1 Ilmu Administrasi Bisnis / NiagaS1 Agroteknologi (Agroindustri, Teknologi Industri Pertanian)AstronomiAgamaDebat Musik, FilmSemua Debat Forum

   
Cari  
    Komputer Sains

    Sebelumnya  (Nuance Communications) (YAM (Yet Another Mailer))  Berikutnya    

Null-terminated string

In computer programming, a null-terminated string is a character string stored as an array containing the characters and terminated with a null character ('\0', called NUL in ASCII). Alternative names are C string, which refers to the C programming language and ASCIIZ (note that C strings do not imply the use of ASCII).

The length of a C string is found by searching for the (first) NUL byte. This can be slow as it takes O(n) (linear time) with respect to the string length. It also means that a NUL cannot be inside the string, as the only NUL is the one marking the end.

Contents

History

Null-terminated strings were produced by the .ASCIZ directive of the PDP-11 assembly languages and the ASCIZ directive of the MACRO-10 macro assembly language for the PDP-10. These predate the development of the C programming language, but other forms of strings were often used.

At the time C (and the languages that it was derived from) were developed, memory was extremely limited, so using only one byte of overhead to store the length of a string was attractive. The only popular alternative at that time, usually called a "Pascal string" (though also used by early versions of BASIC), used a leading byte to store the length of the string. This allows the string to contain NUL and made finding the length need only one memory access (O(1) (constant) time). However, C designer Dennis Ritchie chose to follow the convention of NUL-termination, already established in BCPL,

to avoid the limitation on the length of a string caused by holding the count in an 8- or 9-bit slot, and partly because maintaining the count seemed, in our experience, less convenient than using a terminator.[1]

This had some influence on CPU instruction set design. Some CPUs in the 1970s and 1980s, such as the Zilog Z80 and the DEC VAX, had dedicated instructions for handling length-prefixed strings. However, as the NUL-terminated string gained traction, CPU designers began to take it into account, as seen for example in IBM's decision to add the "Logical String Assist" instructions to the ES/9000 520 in 1992.

FreeBSD developer Poul-Henning Kamp, writing in ACM Queue, would later refer to the victory of the C string over use of a 2-byte (not 1-byte) length as "the most expensive one-byte mistake" ever.[2]

Implementations

C programming language supports null-terminated strings as the primary string type.[3] There are a lot of functions for string handling in the C standard library.

Limitations

While simple to implement, this representation has been prone to errors and performance problems.

The NUL termination has historically created security problems.[4] A NUL byte inserted into the middle of a string will truncate it unexpectedly. A common bug was to not allocate the additional space for the NUL, so it was written over adjacent memory. Another was to not write the NUL at all, often not detected during testing because a NUL was already there. Due to the expense of finding the length, many programs did not bother before copying a string to a fixed-size buffer, causing a buffer overflow if it was too long.

The inability to store a NUL requires that string data and binary data be kept distinct and handled by different functions (with the latter requiring the length of the data to also be supplied). This can lead to code redundancy and errors when the wrong function is used.

The speed problems with finding the length can usually be mitigated by combining it with another operation that is O(n) anyway, such as in strlcpy. However, this does not always result in an intuitive API.

Character encodings

Null-terminated strings require of the encoding that it does not use the 0x00 value for any character. This allows any ASCII extension to be used, also UTF-8, which can also be used directly in source code. UTF-16 uses 2-byte integers and has to use arrays of such, ending with a 2-byte 0x0000 value. UTF-16 can not be used directly in ASCII based source code.

Improvements

Many attempts have been made to make C string handling less error prone. One strategy is to add safer and more useful functions such as strdup and strlcpy, while deprecating the use of unsafe functions such as gets. Another is to add an object-oriented wrapper around C strings so that only safe calls can be done.

On modern systems memory usage is less of a concern, so a multi-byte length is acceptable (if you have so many small strings that the space used by this length is a concern, you will have enough duplicates that a hash table will use even less memory). Most replacements for C strings use a 32-bit or larger length value. Examples include the C++ Standard Template Library std::string, the Qt QString, the MFC CString, and the C-based implementation CFString from Core Foundation as well as its Objective-C sibling NSString from Foundation, both by Apple. More complex structures may also be used to store strings such as the rope.

References

  1. ^ Dennis M. Ritchie (1993). [The development of the C language]. Proc. 2nd History of Programming Languages Conf.
  2. ^ Kemp, Poul-Henning (25 July 2011), "The Most Expensive One-byte Mistake", ACM Queue 9 (7), ISSN 1542-7730, http://queue.acm.org/detail.cfm?id=2010365, retrieved 2 August 2011
  3. ^ Richie, Dennis (2003). "The Development of the C Language". http://cm.bell-labs.com/cm/cs/who/dmr/chist.html. Retrieved 9 November 2011.
  4. ^ Rain Forest Puppy (9 September 1999). "Perl CGI problems". Phrack Magazine (artofhacking.com) 9 (55): 7. http://artofhacking.com/files/phrack/phrack55/P55-07.TXT. Retrieved 6 January 2012.
    Sebelumnya  (Nuance Communications) (YAM (Yet Another Mailer))  Berikutnya    





Tags: Null-terminated string, Komputer Sains, 2243, Null terminated string In computer programming a null terminated string is a character string stored as an array containing the characters and terminated with a null character ( '\0' called NUL in ASCII ), Alternative names are C string which refers to the C programming language and ASCIIZ (note that C strings do not imply the use of ASCII), The length of a C string is found by searching for th, Null-terminated string, Bahasa Indonesia, Contoh Instruksi, Tutorial, Referensi, Buku, Petunjuk m.kelas karyawan ftumj, prestasi.web.id
 Download Brosur / Katalog    Peluang Karir    Program Magister Manajemen (MM)    Pusat Ensiklopedi Bebas    Kuliah Wiraswasta    Soal-Jawab Tes Psikologi    Kuliah Tanpa Uang
Program Kelas Reguler (Hybrid)

Koleksi Jenis Foto
Penerimaan Mahasiswa/i
Program Studi
Layanan + Download
Daftar Situs Kuliah Karyawan
Daftar Situs Perkuliahan Shift
Daftar Situs Semua PTS
Daftar Situs Program Reguler Pagi
Daftar Situs Program Pascasarjana (S2)

 Berbagai Perdebatan    Tutorial Sistem Komputer    Jadwal Sholat    Al Qur'an Online    Program Perkuliahan Shift    Kelas Reguler Pagi    Semua Reklame    Program Perkuliahan Hybrid di 112 PTS Terbaik    Try Out Online Gratis    Pendaftaran Online    Permintaan Beasiswa Kuliah
Sampaikan ke Rekan Anda
Nama Anda

Email Anda

Email Rekan 1

Email Rekan 2 (tidak wajib)

Email Rekan 3 (tidak wajib)
▨ harus diisi dengan benar

Permintaan Katalog / Brosur
(GRATIS via POS)
Nama Lengkap

Alamat Penerima

Provinsi + Kota

Kode Pos

Email (tidak wajib)

⌽ harus diisi lengkap & jelas
Atau kirimkan nama dan
alamat lengkap via SMS ke HP:
0811 1990 9026


Download BROSUR
Brosur Kelas Karyawan
Gabungan Seluruh Wilayah Indonesia

pdf (11,2 MB)ZIP (8,8 MB)
Image/jpg (36,2 MB)
Brosur Kelas Karyawan
JABODETABEK

pdf (5,5 MB)ZIP (4,4 MB)
Image/jpg (13,2 MB)
Brosur Kelas Karyawan
DIY,JATENG,JATIM & BALI

pdf (4,4 MB)ZIP (3,5 MB)
Image/jpg (14,5 MB)
Brosur Kelas Karyawan
JAWA BARAT

pdf (2,8 MB)ZIP (2,2 MB)
Image/jpg (7,1 MB)
Brosur Kelas Karyawan
SULAWESI

pdf (1,9 MB)ZIP (1,5 MB)
Image/jpg (5,6 MB)
Brosur Kelas Karyawan
SUMATERA & BATAM

pdf (2,2 MB)ZIP (1,7 MB)
Image/jpg (6,5 MB)
Brosur Kuliah Reguler
pdf (4,1 Mb)ZIP (8,4 Mb)
Strategi Meningkatkan
Kualitas Pendidikan, Pendapatan dan Sumber Daya PTS

pdf(6 Mb)Image/jpg(16 Mb)

STRATEGI Meningkatkan
Kualitas Pendidikan, Pendapatan dan Sumber Daya PTS
http://kpt.co.id
Terobosan Baru

PT. Gilland Ganesha
Membutuhkan Segera

  • Design Grafis
  • Web Programmer

Penjelasan Lebih Lanjut di :
Info kerja

Arti warna kucing, jadwal vaksinasi kucing, kumpulan foto kucing, dsb.
155 Ras Kucing Populer

Twitter Kuliah Karyawan

Tautan Elok
silakan klik
Sewa Reseller Tanzania
Semua Referensi Dunia

kuliah-karyawan.id  |  dharmaandigha.web.id  |  stih-dharma-andigha.web.id  |  stih-dharmaandigha.web.id  |  suyanto.web.id  |  wiki-indonesia.web.id  |  unkris.my.id  |  p2k.cyber-univ.ac.id  |  p2k.sebi.ac.id  |  stiepasim.web.id  |  s2-uwks.web.id