Developer community
0 votes
53 views
asked by Expert (15k points) 15 23 31 | 53 views

1 Answer

0 votes
An array is an array of anything. A string is a specific kind of an array with a well-known convention to determine its length.
There are two kinds of programming languages: those in which a string is just an array of characters, and those in which it’s a special type. In C, a string is just an array of characters (type char), with one wrinkle: a C string always ends with a NUL character.
The “value” of an array is the same as the address of (or a pointer to) the first element; so, frequently, a C string and a pointer to char are used to mean the same thing.
An array can be any length. If it’s passed to a function, there’s no way the function can tell how long the array is supposed to be, unless some convention is used. The convention for strings is NUL termination; the last character is an ASCII NUL (‘’) character.
answered by Expert (11.4k points) 14 23 30

Related questions

0 votes
1 answer
asked by sunny Expert (11.4k points) 14 23 30 | 25 views
0 votes
1 answer
asked by snag Jr Member (370 points) 1 10 | 62 views
0 votes
1 answer
0 votes
1 answer
asked by keem Expert (13.2k points) 27 43 61 | 58 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users